WARNING: this function is deprecated. Redirection is no longer supported in the latest alabaster framework. Create a redirection to another path in the same staging directory. This is useful for creating short-hand aliases for resources that have inconveniently long paths.

createRedirection(dir, src, dest)

Arguments

dir

String containing the path to the staging directory.

src

String containing the source path relative to dir.

dest

String containing the destination path relative to dir. This may be any path that can also be used in acquireMetadata.

Value

A list of metadata that can be processed by writeMetadata.

Details

src should not correspond to an existing file inside dir. This avoids ambiguity when attempting to load src via acquireMetadata. Otherwise, it would be unclear as to whether the user wants the file at src or the redirection target dest.

src may correspond to existing directories. This is because directories cannot be used in acquireMetadata, so no such ambiguity exists.

Author

Aaron Lun

Examples

# Staging an example DataFrame:
library(S4Vectors)
df <- DataFrame(A=1:10, B=LETTERS[1:10])
tmp <- tempfile()
dir.create(tmp)
info <- stageObject(df, tmp, path="coldata")
writeMetadata(info, tmp)
#> $type
#> [1] "local"
#> 
#> $path
#> [1] "coldata/simple.csv.gz"
#> 

# Creating a redirection:
redirect <- createRedirection(tmp, "foobar", "coldata/simple.csv.gz")
writeMetadata(redirect, tmp)
#> $type
#> [1] "local"
#> 
#> $path
#> [1] "foobar"
#> 

# We can then use this redirect to pull out metadata:
info2 <- acquireMetadata(tmp, "foobar")
str(info2)
#> List of 6
#>  $ $schema       : chr "csv_data_frame/v1.json"
#>  $ path          : chr "coldata/simple.csv.gz"
#>  $ is_child      : logi FALSE
#>  $ data_frame    :List of 4
#>   ..$ columns   :List of 2
#>   .. ..$ :List of 2
#>   .. .. ..$ name: chr "A"
#>   .. .. ..$ type: chr "integer"
#>   .. ..$ :List of 2
#>   .. .. ..$ name: chr "B"
#>   .. .. ..$ type: chr "string"
#>   ..$ row_names : logi FALSE
#>   ..$ dimensions:List of 2
#>   .. ..$ : int 10
#>   .. ..$ : int 2
#>   ..$ version   : int 2
#>  $ csv_data_frame:List of 1
#>   ..$ compression: chr "gzip"
#>  $ md5sum        : chr "042b00e066dfa96577b5d6ac3c3ee700"