find_root_file: File paths relative to the root of a directory hierarchy

View source: R/file.R

find_root_fileR Documentation

File paths relative to the root of a directory hierarchy

Description

find_root_file() is a wrapper around find_root() that appends an arbitrary number of path components to the root using base::file.path().

Usage

find_root_file(..., criterion, path = ".")

find_rstudio_root_file(..., path = ".")

find_package_root_file(..., path = ".")

find_remake_root_file(..., path = ".")

find_testthat_root_file(..., path = ".")

Arguments

...

⁠[character]⁠
Further path components passed to file.path(). All arguments must be the same length or length one.

criterion

⁠[root_criterion]⁠
A criterion, one of the predefined criteria or created by root_criterion(). Will be coerced using as_root_criterion().

path

⁠[character(1)]⁠
The start directory.

Details

This function operates on the notion of relative paths. The ... argument is expected to contain a path relative to the root. If the first path component passed to ... is already an absolute path, the criterion and path arguments are ignored, and ... is forwarded to file.path().

Value

The normalized path of the root as specified by the search criteria, with the additional path components appended. Throws an error if no root is found.

See Also

find_root() utils::glob2rx() base::file.path()

Examples

## Not run: 
find_package_root_file("tests", "testthat.R")
has_file("DESCRIPTION", "^Package: ")$find_file
has_file("DESCRIPTION", "^Package: ")$make_fix_file(".")

## End(Not run)


rprojroot documentation built on Nov. 5, 2023, 5:06 p.m.