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, forceRemote = FALSE)

Arguments

path

String containing the path to the registered (sub)directory.

url

String containing the URL of the SewerRat REST API.

forceRemote

Logical scalar indicating whether to force remote access, even if path is on the same filesystem as the caller.

Value

Character vector of relative paths of files in path.

Author

Aaron Lun

Examples

# 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"