View source: R/build_folders_from_file.R
| build_folders_from_file | R Documentation |
Create Folder Structure from Paths in File
build_folders_from_file( file, target_dir, pattern = NULL, max_depth = NULL, encoding = "Latin-1" )
file |
path to file containing path strings |
target_dir |
path to target directory in which to create the folder structure |
pattern |
regular expression matching the paths from |
max_depth |
maximum folder depth to be considered |
encoding |
encoding used when reading |
# Create a vector of example paths
paths <- c("a1/b1", "a1/b2", "a2/b1", "a2/b1/c1")
# Write the example paths to a temporary file
writeLines(paths, file <- tempfile())
# Create a temporary target directory
target_dir <- kwb.utils::createDirectory(file.path(tempdir(), "test"))
# Create the folder structure as defined by the paths in the temporary file
kwb.fakin::build_folders_from_file(file, target_dir)
# List the directory paths below the target directory
paths_reread <- list.dirs(target_dir, recursive = TRUE, full.names = FALSE)
# Stop if not all paths have been created
stopifnot(all(paths %in% paths_reread))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.