simplifyPath: Simplify folder/directory paths.

View source: R/uri.S

simplifyPathR Documentation

Simplify folder/directory paths.

Description

This is a basic function that removes relative navigation within a directory path. In other words, it attempts to resolve .. and ..

Note that the function does not currently do extensive checking that the result makes sense. To truly do this and to take account of symbolic links, etc., we need to check via the operating system. We also don't worry about drive names (e.g. C:, F:) on Windows systems.

Usage

simplifyPath(path, sep = "/")

Arguments

path

the vector of path strings to simplify.

sep

the directory separator. Since this is used for URIs, we use / as the default. We could use .Platform$file.sep.

Value

A character vector with as many elements.

Author(s)

Duncan Temple Lang <duncan@wald.ucdavis.edu>

See Also

mergeURI dirname

Examples

## Not run: 
simplifyPath("/ab/cdef/ghi")
simplifyPath("/ab/cdef/ghi/..")
simplifyPath("/ab/cdef/../ghi/..")

simplifyPath("./ab/cdef/ghi/..") # "ab/cdef"

simplifyPath("./ab/") # "ab"
simplifyPath("/xyz/./ab/") # "xyz/ab"

## End(Not run)

omegahat/RHTMLForms documentation built on Nov. 29, 2023, 12:36 a.m.