File: find_root.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 (50 lines) | stat: -rw-r--r-- 1,634 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
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/root.R
\name{find_root}
\alias{find_root}
\alias{get_root_desc}
\title{Find the root of a directory hierarchy}
\usage{
find_root(criterion, path = ".")

get_root_desc(criterion, path)
}
\arguments{
\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 criterion.
Throws an error if no root is found
}
\description{
A \emph{root} is defined as a directory that contains a regular file
whose name matches a given pattern and which optionally contains a given text.
The search for a root starts at a given directory (the working directory
by default), and proceeds up the directory hierarchy.

\code{get_root_desc()} returns the description of the criterion
for a root path. This is especially useful for composite root criteria
created with \code{\link[=|.root_criterion]{|.root_criterion()}}.
}
\details{
Starting from the working directory, the \code{find_root()} function searches
for the root.
If a root is found, the \code{...} arguments are used to construct a path;
thus, if no extra arguments are given, the root is returned.
If no root is found, an error is thrown.
}
\examples{
\dontrun{
find_root(glob2rx("DESCRIPTION"), "^Package: ")
}

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