Description Usage Arguments Value Author(s) References See Also Examples
See generic: decomposePath
.
1 2 3 | ## S4 method for signature 'character'
decomposePath(path = ".", dir_slash = FALSE,
shortform = FALSE, ...)
|
path |
|
dir_slash |
|
shortform |
|
... |
Further arguments passed to:
|
character matrix
with three
columns named "dirname"
, "filename"
and "extension"
.
strip_extension
returns a character vector of the second column,
and get_extension
returns a character vector of the third column.
recompose_path
returns a character vector of paths.
Janko Thyson janko.thyson@rappster.de
https://github.com/Rappster/filesystr
decomposePath,
decomposePath-missing-method
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | ## Not run:
## Auxiliary function //
carefulCleanup <- function(x, pattern=basename(tempdir())) {
out <- sapply(x, function(ii) {
out <- NA
if (grepl(pattern, ii)) {
out <- unlink(ii, recursive=TRUE, force=TRUE)
}
out
})
invisible(out)
}
## Create example content //
to_create <- file.path(tempdir(), "decomposePath", c("dir_a", file.path("dir_b", "sub_1")))
sapply(to_create, dir.create, recursive = TRUE, showWarnings = FALSE)
file.create(file.path(tempdir(), "decomposePath/dir_b/sub_1/file.txt"))
## Change working directory //
wd_0 <- getwd()
setwd(file.path(tempdir(), "decomposePath"))
## Make sure you undo this with 'setwd(wd_0)' when you are finished!!!
path <- c(
".",
"..",
"dir_a",
"dir_a/",
"dir_b",
"dir_b/sub_1",
"dir_b/sub_1/file.txt",
"dir_b/sub_1/file.txt/",
"dir_b/nonex",
"dir_b/nonex/",
"dir_b/nonex/file.txt",
"nonex",
"nonex/sub_1",
"nonex/sub_1/file.txt",
"nonex/foo.tgz",
"another nonex\\file.tar.gz",
"a_file",
"quux. quuux.tbz2",
"~/file.tar.xz",
"",
NA_character_
)
res <- decomposePath(path = path)
res
class(res)
decomposePath(path = path, dir_slash = TRUE)
decomposePath(path = path, shortform = TRUE)
decomposePath(path = path, dir_slash = TRUE, shortform = TRUE)
decomposePath()
decomposePath(path = character())
decomposePath(path = NA_character_)
## Clean up //
## Reset working directory:
setwd(wd_0)
## Remove tempdir directory:
carefulCleanup(x = file.path(tempdir(), "decomposePath"))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.