R: Functions for file name and path manipulation

relativePath {tractor.base} | R 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

    relativePath(path, referencePath)

    matchPaths(path, referencePath)

    expandFileName(fileName, base = getwd())

    ensureFileSuffix(fileName, suffix, strip = NULL)

### Arguments

`path, referencePath` | Character vectors whose elements represent file paths.
`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.

### Value

The `ensureFileSuffix` function returns the specified file names with the requested suffixes appended. `expandFileName` returns the full path to the specified file name, collapsing `".."` elements if appropriate. `relativePath` returns the specified `path`, expressed relative to `referencePath`. `matchPaths` resolves a a vector of paths against a vector of reference paths.

### 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. http://www.jstatsoft.org/v44/i08/.

### See Also

`path.expand` performs some of what `expandFileName` does.

[Package tractor.base version 3.2.2 Index]