dirpath_get: Convert file path to directory path

View source: R/args.R

dirpath_getR Documentation

Convert file path to directory path

Description

Takes a file path and converts it to its directory path by dropping the file name and extension. If flpth is already a directory path, the argument will be returned unchanged. If nothing is provided, nothing is returned (i.e. character(0)).

Usage

dirpath_get(flpth)

Arguments

flpth

File path for which directory path will be returned.

Value

Character

Examples

library(outsider.base)
# get the parent directory from a filepath
drpth <- tempdir()
flpth <- file.path(drpth, 'testfile')
file.create(flpth)
(dirpath_get(flpth = flpth) == drpth)
(dirpath_get(flpth = drpth) == drpth)
file.remove(flpth)

ropensci/outsider.base documentation built on June 21, 2022, 7:39 p.m.