retrieveDirectory.Rd
Retrieve the path to a registered directory (or its subdirectories), possibly creating a local copy of the directory's contents if the caller is not on the same filesystem.
retrieveDirectory(
path,
url,
cache = NULL,
forceRemote = FALSE,
overwrite = FALSE,
concurrent = 1,
updateDelay = 3600
)
String containing the absolute path to a registered directory.
String containing the URL to the SewerRat REST API.
String containing a path to a cache directory.
If NULL
, an appropriate location is automatically chosen.
Only used for remote access.
Logical scalar indicating whether to force remote access.
This will download all files in the path
via the REST API and cache them locally,
even if path
is on the same filesystem as the caller.
Logical scalar indicating whether to overwrite the existing cache. Only used for remote access.
Integer scalar specifying the number of concurrent downloads. Only used for remote access.
Integer scalar specifying the maximum age of a cached file, in seconds. Older files will be automatically checked for updates. Only used for remote access.
Path to the subdirectory on the caller's filesystem. This is either a path to the registered (sub)directory if it is accessible, or a path to a local cache of the directory's contents otherwise.
info <- startSewerRat()
# Mocking up a directory of stuff to query.
mydir <- tempfile()
dir.create(mydir)
write(file=file.path(mydir, "foo"), '{ "first": "Aaron", "last": "Lun" }')
dir.create(file.path(mydir, "diet"))
write(file=file.path(mydir, "diet", "bar"),
'{ "meal": "lunch", "ingredients": "water" }')
# Registering it:
register(mydir, "metadata.json", url=info$url)
# Fetching it, either directly or via the API.
retrieveDirectory(mydir, url=info$url)
#> [1] "/tmp/RtmpJDU5Vu/file2174c998a99"
retrieveDirectory(paste0(mydir, "/diet"), url=info$url, forceRemote=TRUE)
#> [1] "/github/home/.local/share/R/SewerRat/http%3A%2F%2F0.0.0.0%3A5114/LOCAL//tmp/RtmpJDU5Vu/file2174c998a99/diet"