listFiles.Rd
List files in a registered directory or a subdirectory thereof. This will call the REST API if the caller is not on the same filesystem.
listFiles(path, url, recursive = TRUE, forceRemote = FALSE)
String containing the path to the registered (sub)directory.
String containing the URL of the SewerRat REST API.
Logical scalar indicating whether to list files recursively.
Logical scalar indicating whether to force remote access,
even if path
is on the same filesystem as the caller.
Character vector of relative paths of files in path
.
# Starting up an example SewerRat service:
info <- startSewerRat()
# Mocking up a directory of stuff to query.
mydir <- tempfile()
dir.create(mydir)
write(file=file.path(mydir, "metadata.json"), '{ "first": "Aaron", "last": "Lun" }')
dir.create(file.path(mydir, "diet"))
write(file=file.path(mydir, "diet", "metadata.json"),
'{ "meal": "lunch", "ingredients": "water" }')
# Registering it:
register(mydir, "metadata.json", url=info$url)
# List files:
listFiles(mydir, url=info$url)
#> [1] "diet/metadata.json" "metadata.json"
listFiles(paste0(mydir, "/diet"), url=info$url)
#> [1] "metadata.json"
# Forcing remote access.
listFiles(mydir, url=info$url, forceRemote=TRUE)
#> [1] "diet/metadata.json" "metadata.json"