File paths relative to the root of a directory hierarchy

Usage

find_root_file(..., filename, contents = NULL, n = -1L, path = getwd())
make_find_root_file(filename, contents = NULL, n = -1L)
make_fix_root_file(filename, contents = NULL, n = -1L)
find_rstudio_root_file(..., path = getwd())
find_package_root_file(..., path = getwd())

Arguments

...
Additional arguments passed to file.path
filename,contents
Regular expressions to match the file name or contents
n
integer. The (maximal) number of lines to read. Negative values indicate that one should read up to the end of input on the connection.
path
The start directory

Value

The normalized path of the root as specified by the search criteria. Throws an error if no root is found

Description

Append an arbitrary number of path components to the root using file.path.

Details

The find_root_file function is a simple wrapper around find_root that appends an arbitrary number of path components to the root using file.path. The function make_find_root_file can be used to create shorthand functions such as find_rstudio_root_file and find_package_root_file. In many cases, the function make_fix_root_file is even more useful: It creates a shorthand function that is tied to a fixed root (as opposed to make_find_root_file which creates a function that will look for the root every time it is called).

Examples

## Not run: # find_package_root_file("tests", "testthat.R") # make_find_root_file(glob2rx("DESCRIPTION"), "^Package: ") # make_fix_root_file(glob2rx("DESCRIPTION"), "^Package: ") # ## End(Not run)