Debian Codegraph @

man/existing_files.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/paths.R
3 \name{existing_files}
4 \alias{existing_files}
5 \title{Find file paths that exist}
6 \usage{
7 existing_files(x, first = FALSE, error = TRUE)
8 }
9 \arguments{
10 \item{x}{A vector of file paths.}
11
12 \item{first}{Whether to return the first existing path. If \code{TRUE} and no
13 specified files exist, it will signal an error unless the argument
14 \code{error = FALSE}.}
15
16 \item{error}{Whether to throw an error when \code{first = TRUE} but no files
17 exist. It can also take a character value, which will be used as the error
18 message.}
19 }
20 \value{
21 A vector of existing file paths.
22 }
23 \description{
24 This is a shorthand of \code{x[file.exists(x)]}, and optionally returns the
25 first existing file path.
26 }
27 \examples{
28 xfun::existing_files(c("foo.txt", system.file("DESCRIPTION", package = "xfun")))
29 }