Functions for expanding file paths, finding relative paths and ensuring that a file name has the required suffix.
resolvePath(path, ...)relativePath(path, referencePath)
matchPaths(path, referencePath)
registerPathHandler(regex, handler)
expandFileName(fileName, base = getwd())
ensureFileSuffix(fileName, suffix, strip = NULL)
A character vector.
Character vectors whose elements represent file paths (which may or may not currently exist).
Additional arguments to custom path handlers.
A Ruby-style regular expression.
A function taking and returning a string.
A character vector of file names.
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.
A character vector of file suffixes, which will be recycled if
shorter than fileName
.
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.
Jon Clayden
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).
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. tools:::Rd_expr_doi("10.18637/jss.v044.i08").
normalizePath
does most of the work for
expandFileName
.