File: find_root_file.Rd

package info (click to toggle)
r-cran-rprojroot 2.0.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 496 kB
  • sloc: sh: 12; makefile: 7
file content (61 lines) | stat: -rw-r--r-- 2,073 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/file.R, R/shortcut.R
\name{find_root_file}
\alias{find_root_file}
\alias{find_rstudio_root_file}
\alias{find_package_root_file}
\alias{find_remake_root_file}
\alias{find_testthat_root_file}
\title{File paths relative to the root of a directory hierarchy}
\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{
\item{...}{\verb{[character]}\cr
Further path components passed to \code{\link[=file.path]{file.path()}}.
All arguments must be the same length or length one.}

\item{criterion}{\verb{[root_criterion]}\cr
A criterion, one of the predefined \link{criteria}
or created by \code{\link[=root_criterion]{root_criterion()}}.
Will be coerced using \code{\link[=as_root_criterion]{as_root_criterion()}}.}

\item{path}{\verb{[character(1)]}\cr
The start directory.}
}
\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.
}
\description{
\code{find_root_file()} is a wrapper around \code{\link[=find_root]{find_root()}} that
appends an arbitrary number of path components to the root using
\code{\link[base:file.path]{base::file.path()}}.
}
\details{
This function operates on the notion of relative paths.
The \code{...} argument is expected to contain a path relative to the root.
If the first path component passed to \code{...} is already an absolute path,
the \code{criterion} and \code{path} arguments are ignored,
and \code{...} is forwarded to \code{\link[=file.path]{file.path()}}.
}
\examples{
\dontrun{
find_package_root_file("tests", "testthat.R")
has_file("DESCRIPTION", "^Package: ")$find_file
has_file("DESCRIPTION", "^Package: ")$make_fix_file(".")
}

}
\seealso{
\code{\link[=find_root]{find_root()}} \code{\link[utils:glob2rx]{utils::glob2rx()}} \code{\link[base:file.path]{base::file.path()}}
}