R/fsutils.r
split_path.RdSplit file path into individual components (optionally including separators)
split_path(
path,
include.fseps = FALSE,
omit.duplicate.fseps = FALSE,
fsep = .Platform$file.sep
)A path with directories separated by fseps.
Whether to include the separators in the returned
character vector (default FALSE)
Whether to omit duplicate file separators if
include.fseps=TRUE (default FALSE).
The path separator (default to .Platform$file.sep)
A character vector with one element for each component in the path
(including path separators if include.fseps=TRUE).
Other path_utils:
abs2rel(),
common_path()
split_path("/a/b/c")
#> [1] "a" "b" "c"
split_path("a/b/c")
#> [1] "a" "b" "c"
parts=split_path("/a/b/c", include.fseps=TRUE)
# join parts back up again
paste(parts, collapse = "")
#> [1] "/a/b/c"
split_path("a/b//c", include.fseps=TRUE, omit.duplicate.fseps=TRUE)
#> [1] "a" "/" "b" "/" "c"
# Windows style
split_path("C:\\a\\b\\c", fsep="\\")
#> [1] "C:" "a" "b" "c"