WARNING: this function is deprecated, use listObjects
and loop over entries with readObject
instead.
As the title suggests, this function loads all non-child objects in a staging directory.
All loading is performed using altLoadObject
to respect any application-specific overrides.
Children are used to assemble their parent objects and are not reported here.
loadDirectory(dir, redirect.action = c("from", "to", "both"))
String containing a path to a staging directory.
String specifying how redirects should be handled:
"to"
will report an object at the redirection destination, not the redirection source.
"from"
will report an object at the redirection source(s), not the destination.
"both"
will report an object at both the redirection source(s) and destination.
A named list is returned containing all (non-child) R objects in dir
.
tmp <- tempfile()
dir.create(tmp)
library(S4Vectors)
df <- DataFrame(A=1:10, B=LETTERS[1:10])
meta <- stageObject(df, tmp, path="whee")
writeMetadata(meta, tmp)
#> $type
#> [1] "local"
#>
#> $path
#> [1] "whee/simple.csv.gz"
#>
ll <- list(A=1, B=LETTERS, C=DataFrame(X=1:5))
meta <- stageObject(ll, tmp, path="stuff")
writeMetadata(meta, tmp)
#> $type
#> [1] "local"
#>
#> $path
#> [1] "stuff/list.json.gz"
#>
redirect <- createRedirection(tmp, "whoop", "whee/simple.csv.gz")
writeMetadata(redirect, tmp)
#> $type
#> [1] "local"
#>
#> $path
#> [1] "whoop"
#>
all.meta <- loadDirectory(tmp)
str(all.meta)
#> List of 2
#> $ stuff/list.json.gz:List of 3
#> ..$ A: num 1
#> ..$ B: chr [1:26] "A" "B" "C" "D" ...
#> ..$ C:Formal class 'DFrame' [package "S4Vectors"] with 6 slots
#> .. .. ..@ rownames : NULL
#> .. .. ..@ nrows : int 5
#> .. .. ..@ elementType : chr "ANY"
#> .. .. ..@ elementMetadata: NULL
#> .. .. ..@ metadata : list()
#> .. .. ..@ listData :List of 1
#> .. .. .. ..$ X: int [1:5] 1 2 3 4 5
#> $ whoop :Formal class 'DFrame' [package "S4Vectors"] with 6 slots
#> .. ..@ rownames : NULL
#> .. ..@ nrows : int 10
#> .. ..@ elementType : chr "ANY"
#> .. ..@ elementMetadata: NULL
#> .. ..@ metadata : list()
#> .. ..@ listData :List of 2
#> .. .. ..$ A: int [1:10] 1 2 3 4 5 6 7 8 9 10
#> .. .. ..$ B: chr [1:10] "A" "B" "C" "D" ...