ext: File Extensions

extR Documentation

File Extensions

Description

splitext() 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.

Usage

splitext(path, compression = FALSE)
removeext(path, compression = FALSE)
ext(path, compression = FALSE)
ext(path, compression = FALSE) <- value

Arguments

path

character vector, containing path names.

compression

should compression extensions \string.gz, \string.bz2, and \string.xz be taken into account when removing / / getting an extension?

value

a character vector, typically of length 1 or length(path), or NULL.

Details

Tilde-expansion (see \codelink4?basepath.expand()) of the path will be performed.

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)).

Value

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.

Examples

splitext(character(0))
splitext("")

splitext("file.ext")

path <- c("file.tar.gz", "file.tar.bz2", "file.tar.xz")
splitext(path, compression = FALSE)
splitext(path, compression = TRUE)

path <- "@R_PACKAGE_NAME@_@R_PACKAGE_VERSION@.tar.gz"
ext(path) <- ".png"
path

path <- "@R_PACKAGE_NAME@_@R_PACKAGE_VERSION@.tar.gz"
ext(path, compression = TRUE) <- ".png"
path

ArcadeAntics/this.path documentation built on July 27, 2024, 12:05 a.m.