\HeaderA{Sys.glob}{Wildcard Expansion on File Paths}{Sys.glob}
\keyword{utilities}{Sys.glob}
\keyword{file}{Sys.glob}
\begin{Description}\relax
Function to do wildcard expansion (also known as \sQuote{globbing}) on
file paths.

Platforms are not required to support this, but all known current \R{}
platforms do.
\end{Description}
\begin{Usage}
\begin{verbatim}
Sys.glob(paths, dirmark = FALSE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{paths}] character vector of patterns for relative or absolute
filepaths.  Missing values will be ignored.
\item[\code{dirmark}] logical: should matches to directories from patterns
that do not already end in \code{/}
have a slash appended?  May not be supported on all platforms.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
This expands wildcards in file paths.  For precise details, see your
system's documentation on the \code{glob} system call.  There is a
POSIX 1003.2 standard (see
\url{http://www.opengroup.org/onlinepubs/009695399/functions/glob.html})
but some OSes will go beyond this.  The \R{} implementation will always
do tilde-expansion (see \code{\LinkA{path.expand}{path.expand}}).

All systems should interpret \code{*} (match zero or more characters),
\code{?} (match a single character) and (probably) \code{[} (begin a
character class or range).  If a filename starts with \code{.} this
must be matched explicitly.  By default paths ending in \code{/} will
be accepted and matched only to directories.

The rest of these details are indicative (and based on the POSIX
standard).

\code{[} begins a character class.  If the first character in
\code{[...]} is not \code{!}, this is a character class which matches
a single character against any of the characters specified.  The class
cannot be empty, so \code{]} can be included provided it is first.  If
the first character is \code{!}, the character class matches a single
character which is \emph{none} of the specified characters.

Character classes can include ranges such as \code{[A-Z]}: include
\code{-} as a character by having it first or last in a class.  (The
interpretation of ranges should be locale-specific, so the example is
not a good idea in an Estonian locale.)

One can remove the special meaning of \code{?}, \code{*}  and
\code{[} by preceding them by a backslash (except within a
character class).
\end{Details}
\begin{Value}
A character vector of matched file paths.  The order is
system-specific (but in the order of the elements of \code{paths}):
it is normally collated in either the current locale or in byte (ASCII) order.

Directory errors are normally ignored, so the matches are to
accessible file paths (but not necessarily accessible files).

On platforms which do not have the \code{glob} system call,
\code{paths} is returned unchanged.
\end{Value}
\begin{SeeAlso}\relax
\code{\LinkA{path.expand}{path.expand}}.

\LinkA{Quotes}{Quotes} for handling backslashes in character strings.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
## Not run: 
Sys.glob(file.path(R.home(), "library", "*", "R", "*.rdx"))
## End(Not run)\end{ExampleCode}
\end{Examples}

