% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/RcppExports.R
\name{vsi_glob}
\alias{vsi_glob}
\title{Get file and directory names matching a pattern that may contain wildcards}
\usage{
vsi_glob(pattern, show_progress = FALSE)
}
\arguments{
\item{pattern}{Character string. The relative or absolute path of a
directory to read, potentially containing wildcards, assumed to be UTF-8
encoded (see Details).}

\item{show_progress}{Logical scalar. If \code{TRUE}, a progress bar will be
displayed. Default is \code{FALSE}.}
}
\value{
A character vector containing the matching names of files and
directories.
}
\description{
\code{vsi_glob()} returns a character vector of file and directory names matching
a pattern that can contain wildcards. This function has similar behavior to
the POSIX \code{glob()} function. Wrapper of \code{VSIGlob()} in the GDAL Common
Portability Library. Requires GDAL >= 3.11.
}
\details{
The following wildcards are supported
\itemize{
\item \code{*}: match any string
\item \verb{?}: match any single character
\item \code{[}: match character class or range, with \code{!} immediately after \code{[} to
indicate negation
}

Refer to to the \code{glob()} man page for more details
(\url{https://man7.org/linux/man-pages/man7/glob.7.html}).
It also supports the \verb{**} recursive wildcard, behaving similarly to Python
\code{glob.glob()} with \code{recursive = True}. Be careful of the amount of memory
and time required when using the recursive wildcard on directories with a
large amount of files and subdirectories.

Examples, given a file hierarchy:
\itemize{
\item \code{one.tif}
\item \code{my_subdir/two.tif}
\item \code{my_subdir/subsubdir/three.tif}
}

\if{html}{\out{<div class="sourceCode">}}\preformatted{vsi_glob("one.tif")
  # returns ("one.tif")
vsi_glob("*.tif")
  # returns ("one.tif")
vsi_glob("on?.tif")
  # returns ("one.tif")
vsi_glob("on[a-z].tif")
  # returns ("one.tif")
vsi_glob("on[ef].tif")
  # returns ("one.tif")
vsi_glob("on[!e].tif")
  # returns empty vector character()
vsi_glob("my_subdir/*.tif")
  # returns ("my_subdir/two.tif")
vsi_glob("**/*.tif") returns
  # returns ("one.tif", "my_subdir/two.tif", "my_subdir/subsubdir/three.tif")
}\if{html}{\out{</div>}}

In the current implementation, matching is done based on the assumption that
a character fits into a single byte, which will not work properly on
non-ASCII UTF-8 filenames.
}
\note{
GDAL's \code{VSIGlob()} works with any virtual file systems supported by GDAL,
including network file systems such as /vsis3/, /vsigs/, /vsiaz/, etc. But
note that for those, the pattern is not passed to the remote server, and
thus a large amount of filenames can be transferred from the remote server
to the host where the filtering is done.
}
\examples{
\dontshow{if (gdal_version_num() >= gdal_compute_version(3, 11, 0)) withAutoprint(\{ # examplesIf}
# Requires GDAL >= 3.11
data_dir <- system.file("extdata", package="gdalraster")
vsi_glob(file.path(data_dir, "ynp*"))
\dontshow{\}) # examplesIf}
}
\seealso{
\code{\link[=vsi_read_dir]{vsi_read_dir()}}
}
