Given a path, try to find it recursively under a root directory. The input
path can be an incomplete path, e.g., it can be a base filename, and
magic_path()
will try to find this file under subdirectories.
A character vector of path components.
The root directory under which to search for the path. If
NULL
, the current working directory is used.
Whether to return a relative path.
Whether to signal an error if the path is not found, or multiple paths are found.
Whether to emit a message when multiple paths are found and
error = FALSE
.
The number of subdirectories to recursively search. The
recursive search may be time-consuming when there are a large number of
subdirectories under the root directory. If you really want to search for
all subdirectories, you may try n_dirs = Inf
.
The path found under the root directory, or an error when error = TRUE
and the path is not found (or multiple paths are found).
if (FALSE) { # \dontrun{
xfun::magic_path("mtcars.csv") # find any file that has the base name mtcars.csv
} # }