Rev 49383 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/base/man/Sys.glob.Rd% Part of the R package, http://www.R-project.org% Copyright 1995-2009 R Core Development Team% Distributed under GPL 2 or later\name{Sys.glob}\alias{Sys.glob}\title{Wildcard Expansion on File Paths}\description{Function to do wildcard expansion (also known as \sQuote{globbing}) onfile paths.}\usage{Sys.glob(paths, dirmark = FALSE)}\arguments{\item{paths}{character vector of patterns for relative or absolutefilepaths. Missing values will be ignored.}\item{dirmark}{logical: should matches to directories from patternsthat do not already end in \code{/}#ifdef windowsor \code{\\}#endifhave a slash appended? May not be supported on all platforms.}}\details{#ifdef unixThis expands wildcards in file paths. For precise details, see yoursystem's documentation on the \code{glob} system call. There is aPOSIX 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 alwaysdo tilde-expansion (see \code{\link{path.expand}}).All systems should interpret \code{*} (match zero or more characters),\code{?} (match a single character) and (probably) \code{[} (begin acharacter class or range). If a filename starts with \code{.} thismust be matched explicitly. By default paths ending in \code{/} willbe accepted and matched only to directories.The rest of these details are indicative (and based on the POSIXstandard).\code{[} begins a character class. If the first character in\code{[...]} is not \code{!}, this is a character class which matchesa single character against any of the characters specified. The classcannot be empty, so \code{]} can be included provided it is first. Ifthe first character is \code{!}, the character class matches a singlecharacter 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. (Theinterpretation of ranges should be locale-specific, so the example isnot 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 acharacter class).#endif#ifdef windowsThe \code{glob} system call is not part of Windows, and we supply apartial emulation.Wildcards are \code{*} (match zero or more characters) and \code{?} (matcha single character). If a filename starts with \code{.} this must bematched explicitly.In addition, \code{[} begins a character class. If the firstcharacter in \code{[...]} is not \code{!}, this is a character classwhich matches a single character against any of the charactersspecified. The class cannot be empty, so \code{]} can be includedprovided it is first. If the first character is \code{!}, thecharacter class matches a single character which is \emph{none} of thespecified 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. (In thecurrent implementation ranges are in numeric order of Unicode points.)One can remove the special meaning of \code{?}, \code{*} and\code{[} by preceding them by a backslash (except within acharacter class). Note that on Windows \code{?} and \code{*} are notvalid in file names, so this is mainly for consistency with otherplatforms.File paths in Windows are interpreted with separator \code{\\} or\code{/}. Paths with a drive but relative (such as \code{c:foo\\bar})are tricky, but an attempt is made to handle them correctly. As from\R 2.9.2 an attempt is made to handle UNC paths starting with a doublebackslash.#endif}\value{A character vector of matched file paths. The order issystem-specific (but in the order of the elements of \code{paths}):#ifdef unixit is normally collated in either the current locale or in byte (ASCII) order.#endif#ifdef windowson Windows collation is in the order of Unicode points.#endifDirectory errors are normally ignored, so the matches are toaccessible file paths (but not necessarily accessible files).}\seealso{\code{\link{path.expand}}.\link{Quotes} for handling backslashes in character strings.}\examples{\dontrun{Sys.glob(file.path(R.home(), "library", "*", "R", "*.rdx"))}}\keyword{utilities}\keyword{file}