ext.Rdsplitext() splits an extension from a path.
removeext() removes an extension from a path.
ext() gets the extension of a path.
ext<-() sets the extension of a path.
splitext(path, compression = FALSE, expand = TRUE)
removeext(path, compression = FALSE, expand = TRUE)
ext(path, compression = FALSE, expand = TRUE)
ext(path, compression = FALSE, expand = TRUE) <- valuecharacter vector, containing path names.
should compression extensions ".gz", ".bz2",
and ".xz" be taken into account when removing / / getting an
extension?
logical. Should tilde (see path.expand) be
expanded?
a character vector, typically of length
1 or length(path), or NULL.
Trailing path separators are removed before dissecting the path.
Except for path <- NA_character_, it will always be true that
path == paste0(removeext(path), ext(path)).
for splitext(), a matrix with 2 rows and
length(path) columns. The first row will be the roots of the paths,
the second row will be the extensions of the paths.
for removeext() and ext(), a character vector the same length
as path.
for ext<-(), the updated object.
splitext(character(0))
#>
#> root
#> ext
splitext("")
#> [,1]
#> root ""
#> ext ""
splitext("file.ext")
#> [,1]
#> root "file"
#> ext ".ext"
path <- c("file.tar.gz", "file.tar.bz2", "file.tar.xz")
splitext(path, compression = FALSE)
#> [,1] [,2] [,3]
#> root "file.tar" "file.tar" "file.tar"
#> ext ".gz" ".bz2" ".xz"
splitext(path, compression = TRUE)
#> [,1] [,2] [,3]
#> root "file" "file" "file"
#> ext ".tar.gz" ".tar.bz2" ".tar.xz"
path <- "@R_PACKAGE_NAME@_@R_PACKAGE_VERSION@.tar.gz"
ext(path) <- ".png"
path
#> [1] "@R_PACKAGE_NAME@_@R_PACKAGE_VERSION@.tar.png"
path <- "@R_PACKAGE_NAME@_@R_PACKAGE_VERSION@.tar.gz"
ext(path, compression = TRUE) <- ".png"
path
#> [1] "@R_PACKAGE_NAME@_@R_PACKAGE_VERSION@.png"