WARNING: this function is deprecated, as directories of non-child objects can just be deleted with regular methods (e.g., file.rename) in the latest version of alabaster. Pretty much as it says in the title. This only works with non-child objects as children are referenced by their parents and cannot be safely removed in this manner.

removeObject(dir, path)

Arguments

dir

String containing the path to the staging directory.

path

String containing the path to a non-child object inside dir, as used in acquireMetadata. This can also be a redirection to such an object.

Value

The object represented by path is removed, along with any redirections to it. A NULL is invisibly returned.

Details

This function will search around path for JSON files containing redirections to path, and remove them. More specifically, if path is a subdirectory, it will search in the same directory containing path; otherwise, it will search in the directory containing dirname(path). Redirections in other locations will not be removed automatically - these will be caught by checkValidDirectory and should be manually removed.

Author

Aaron Lun

Examples

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

list.files(tmp, recursive=TRUE)
#> [1] "stuff/child-1/simple.csv.gz"      "stuff/child-1/simple.csv.gz.json"
#> [3] "stuff/list.json.gz"               "stuff/list.json.gz.json"         
#> [5] "whee/simple.csv.gz"               "whee/simple.csv.gz.json"         
#> [7] "whoop.json"                      
removeObject(tmp, "whoop")
list.files(tmp, recursive=TRUE)
#> [1] "stuff/child-1/simple.csv.gz"      "stuff/child-1/simple.csv.gz.json"
#> [3] "stuff/list.json.gz"               "stuff/list.json.gz.json"