dirpath_get: Convert file path to directory path

Description Usage Arguments Value Examples

View source: R/args.R

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

1
dirpath_get(flpth)

Arguments

flpth

File path for which directory path will be returned.

Value

Character

Examples

1
2
3
4
5
6
7
8
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)

outsider.base documentation built on April 19, 2021, 1:06 a.m.