decompose_path splits a path into the directory name, filename
without extension, and extension.
replace_extension provide shortcuts to
manipulate the file extension.
recompose_path takes the result of
decompose_path and returns complete paths.
1 2 3 4 5 6 7 8 9 10 11 12
A character vector of file paths. Defaults to files in the current directory.
Not currently used.
A new extension to replace the existing ones.
Should the directory part of the path be included? If
decompose_path returns a character matrix with three
strip_extension returns a character vector of the filename, possibly
with a directory (see
replace_extension returns a character vector of the filename with a
newextension, possibly with a directory (see
get_extension returns a character vector of the third column.
recompose_path returns a character vector of paths.
A few of the tests for this function don't pass under the CRAN Windows machine. It is unclear exactly why this is happening, and the failing tests have not been reproduced elsewhere. If you have unexpected behaviour with this function, please report it on the package issue tracker. https://github.com/richierocks/pathological/issues
Decomposing and then recomposing a path is usually equivalent to
standardizing that path (though slower). That is, usually
recompose_path(decompose_path(x)) == standardize_path(x).
One exception to this is when the directory of x is a symbolic link to
another directory. In this case
decompose_path will follow the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
x <- c( "somedir/foo.tgz", # single extension "another dir\\bar.tar.gz", # double extension "baz", # no extension "quux. quuux.tbz2", # single ext, dots in filename R.home(), # a dir "~", # another dir "~/quuuux.tar.xz", # a file in a dir "", # empty ".", # current dir "..", # parent dir NA_character_ # missing ) (decomposed <- decompose_path(x)) get_extension(x) strip_extension(x) strip_extension(x, FALSE) recompose_path(decomposed)