src_mowerplus <- function(backup_id, data_loc = "~/Data", overwrite = TRUE) {
require(XML, quietly = TRUE, warn.conflicts = FALSE) # to read plist (property list) files
require(tidyverse, quietly = TRUE, warn.conflicts = FALSE) # for printing and access to sqlite dbs
# root of mobile backup dir for `backup_id`
mb <- path.expand(file.path("~/Library/Application Support/MobileSync/Backup", backup_id))
stopifnot(dir.exists(mb))
data_loc <- path.expand(data_loc)
stopifnot(dir.exists(data_loc))
tf <- tempfile(fileext = ".sqlite")
on.exit(unlink(tf), add=TRUE)
# path to the extracted sqlite file
out_db <- file.path(data_loc, "mowtrack.sqlite")
file.copy(file.path(mb, "Manifest.db"), tf, overwrite = TRUE)
manifest_db <- src_sqlite(tf)
fils <- tbl(manifest_db, "Files")
filter(fils, relativePath == "Library/Application Support/MowTracking.sqlite") %>%
pull(fileID) -> mowtrackdb_loc
file.copy(
file.path(mb, sprintf("%s/%s", substr(mowtrackdb_loc, 1, 2), mowtrackdb_loc)),
file.path(data_loc, "mowtrack.sqlite"),
overwrite = overwrite
)
src_sqlite(out_db)
}