paths: Functions for file name and path manipulation

resolvePathR Documentation

Functions for file name and path manipulation

Description

Functions for expanding file paths, finding relative paths and ensuring that a file name has the required suffix.

Usage

resolvePath(path, ...)

relativePath(path, referencePath)

matchPaths(path, referencePath)

registerPathHandler(regex, handler)

expandFileName(fileName, base = getwd())

ensureFileSuffix(fileName, suffix, strip = NULL)

Arguments

path, referencePath

Character vectors whose elements represent file paths (which may or may not currently exist).

...

Additional arguments to custom path handlers.

regex

A Ruby-style regular expression.

handler

A function taking and returning a string.

fileName

A character vector of file names.

base

If fileName is a relative path, this option gives the base directory which the path is relative to. If fileName is an absolute path, this argument is ignored.

suffix

A character vector of file suffixes, which will be recycled if shorter than fileName.

strip

A character vector of suffixes to remove before appending suffix. The intended suffix does not need to be given here, as the function will not append it if the specified file name already has the correct suffix.

Details

The resolvePath function passes its arguments elementwise through any matching path handler, and returns the resolved paths. Nonmatching elements are returned as-is. registerPathHandler registers a new path handler for special syntaxes, and is for advanced use only. relativePath returns the specified path, expressed relative to referencePath. matchPaths resolves a vector of paths against a vector of reference paths. expandFileName returns the full path to the specified file name, collapsing ".." elements if appropriate. ensureFileSuffix returns the specified file names with the requested suffixes appended (if they are not already).

Value

A character vector.

Author(s)

Jon Clayden

References

Please cite the following reference when using TractoR in your work:

J.D. Clayden, S. Muñoz Maniega, A.J. Storkey, M.D. King, M.E. Bastin & C.A. Clark (2011). TractoR: Magnetic resonance imaging and tractography with R. Journal of Statistical Software 44(8):1-18. https://www.jstatsoft.org/v44/i08/.

See Also

normalizePath does most of the work for expandFileName.


tractor.base documentation built on Aug. 24, 2022, 5:06 p.m.