path_split_drive: Split a pathname into drive/UNC sharepoint and relative path...

Description Usage Arguments Details Value Examples

View source: R/split_drive.R

Description

Returns a 2 element list with character vectors: drive/UNC and path, either part may contain empty strings ("") but both will have the same length as the input.

Usage

1

Arguments

path

Character vector.

Details

It always holds that paste0(output[1], output[2]) == input (note that this means that the path part is an absolute path, including a leading slash, when a drive or UNC mountpoint is present).

If the path contained a drive letter, the drive/UNC part will contain everything up to and including the colon. E.g. path_split_drive("c:/dir") returns list(drive = "c:", path = "/dir").

If the path contained a UNC path, the drive/UNC will contain the host name and share up to but not including the fourth directory separator character. E.g. path_split_drive("//host/computer/dir") returns list(drive = "//host/computer", path = "/dir").

Paths cannot contain both a drive letter and a UNC path.

Note that this differs from the Python os.path module in that UNC parts are considered drives here.

Value

List of character vectors of length two. The first elements contain the drive letters or UNC paths, the second elements the relative paths.

Examples

1
# path_split_drive(c("c:/Rtools/bin", "\\\\machine\\share\\folder"))

richfitz/pathr documentation built on May 27, 2019, 8:22 a.m.