This function gets a data frame containing path information as input. It
filters for rows with value "file" in column type and keeps only the
columns path and size. If pattern is not NULL,
the data frame is then filtered for rows in which path matches the
given pattern. Finally, the common root of all paths in column path is
removed and the resulting data frame is returned.
Arguments
- path_info
data frame containing file path information as returned by
read_file_info- pattern
pattern by which to select a subset of paths or
NULL(default) if all paths inpath_infoare to be considered. By setting the pattern to "^/path/to/start/directory" you can "zoom into" the path tree, returning only the contents of "/path/to/start/directory".
Examples
path_info <- kwb.utils::noFactorDataFrame(
path = c("/path/to/root/", "/path/to/root/file_1", "/path/to/root/file_2"),
type = c("directory", "file", "file"),
size = c(0L, 10L, 20L)
)
path_info
#> path type size
#> 1 /path/to/root/ directory 0
#> 2 /path/to/root/file_1 file 10
#> 3 /path/to/root/file_2 file 20
kwb.fakin:::prepare_path_data(path_info)
#> Splitting paths ... ok. (0.00s)
#> Removing the first 4 path segments ... ok. (0.00s)
#> Putting path segments together ... ok. (0.00s)
#> path size
#> 2 file_1 10
#> 3 file_2 20