File depth

fileDepth(path, fsep = .Platform[["file.sep"]])

Arguments

path

character. File path(s). This function is vectorized and supports multiple files.

fsep

character(1). Platform-specific file path separator (e.g. "/" on Unix).

Value

integer. Unnamed vector denoting file path depth. Note that "/" will return 0 here (zero indexed).

Note

This function intentionally doesn't check whether a file exists.

Updated 2019-09-05.

Examples

a <- tempdir() b <- tempfile() fileDepth(c(a, b))
#> [1] 7 8