fs_basename: filename/path extension object

Description Usage Arguments Details Value See Also Examples

View source: R/fs_basename.R

Description

A filename extension object allowing for extensions containing .

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
fs_basename(x = NULL)

## S3 method for class 'fs_basename'
print(x, ...)

as_fs_basename(x, ...)

## Default S3 method:
as_fs_basename(x, ...)

## S3 method for class 'fs_path'
as_fs_basename(x, exts = getOption("fs.exts"))

path_basename(x, exts = getOptions("fs.exts"))

Arguments

x

object; values to be converted to character. Character values should omitting the leading . (period)

exts

character allowable extensions

Details

fs_basename() provides a object for handling file/path extensions. This is a character vector with a subclass ext that allows methods to be written for it.

as_fs_basename returns the extension of its argument x.

If x is a If x is a fs_path object and exts is provided, x will identify extensions will match these extensions first. This allows for extensions with more than one . in the filename. Otherwise, fs::path_ext() is used and the extension is the character following the last . in the path or filename.

Missing extensions are encoded as an empty string ("").

Value

a fs_basename() object.

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
  fs_basename( qw(one, two, three) )

  file <- "my_file.rds"
  as_fs_basename(file)

  file <- file %>% fs::path()
  as_fs_basename(file)
  as_fs_basename(file, c('sql', 'rds', 'sql.rds'))


  "iris.rds" %>%

decisionpatterns/cache documentation built on June 15, 2020, 9:35 p.m.