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
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/paths.R
\name{existing_files}
\alias{existing_files}
\title{Find file paths that exist}
\usage{
existing_files(x, first = FALSE, error = TRUE)
}
\arguments{
\item{x}{A vector of file paths.}
\item{first}{Whether to return the first existing path. If \code{TRUE} and no
specified files exist, it will signal an error unless the argument
\code{error = FALSE}.}
\item{error}{Whether to throw an error when \code{first = TRUE} but no files
exist. It can also take a character value, which will be used as the error
message.}
}
\value{
A vector of existing file paths.
}
\description{
This is a shorthand of \code{x[file.exists(x)]}, and optionally returns the
first existing file path.
}
\examples{
xfun::existing_files(c("foo.txt", system.file("DESCRIPTION", package = "xfun")))
}
|