SYNOPSIS
#include <glob.h>
int glob(const char *pattern, int flags, int (*errfunc)(const char *epath, int eerrno), glob_t *pglob);
DESCRIPTION
The
Member Type | Member Name | Description |
size_t | gl_pathc | Count of paths matched by the specified pattern. |
char ** | gl_pathv | Pointer to a list of matched path names. |
size_t | gl_offs | Slots to reserve at the beginning of gl_pathv. |
The pattern parameter is
a pointer to a path name pattern to be expanded. The
* ? [
The
It is the caller's
responsibility to create the structure pointed to by pglob.
The
The flags argument is used to
control the behavior of
- GLOB_APPEND
-
Append path names generated to the ones from a previous call to
glob() . - GLOB_DOOFFS
-
Make use of the gl_offs member of pglob. If this flag is set, the gl_offs member is used to specify how many null pointers to add to the beginning of the gl_pathv array. In other words, the gl_pathv array points to gl_offs null pointers, followed by gl_pathcpath name pointers, followed by a null pointer.
- GLOB_ERR
-
Causes
glob() to return when it encounters a directory that it cannot open or read. Ordinarily,glob() continues to find matches. - GLOB_MARK
-
Each path name that is a directory that matches the pattern has a slash appended to the name.
- GLOB_NOCASE
-
Ignore case when performing pattern matching and sorting.
- GLOB_NOCHECK
-
If the specified pattern does not match any path name,
glob() returns a list consisting of pattern, and the number of matched path names is 1. - GLOB_NOESCAPE
-
Disable backspace escaping.
- GLOB_NOSORT
-
Do not sort the path name list. The order of the returned path names is unspecified.
The GLOB_APPEND flag can be used to append a new set of
path names to those found in a previous call to
- The first such call must not set GLOB_APPEND. All subsequent calls must set it.
- All the calls must set GLOB_DOOFFS, or all must not set it.
- After the second call, the gl_pathv member points to a list containing the following:
- The count returned in the gl_pathc member is the total number of path names from the two calls.
- The application can change any of the fields after a call to
glob() . If it does, it must reset them to the original value before a subsequent call, using the same pglob value, toglobfree() or toglob() with the GLOB_APPEND flag.
If, during the search, a directory is encountered that cannot be opened
or read, and errfunc is not a null pointer,
- The epath parameter is a pointer to the path that failed.
- The eerrno parameter is the value of errno
from the failure, as set by
opendir() ,readdir() , orstat() .
If (*
PARAMETERS
- pattern
-
Points to the path name pattern to be expanded.
- flags
-
Controls the behavior of
glob() . The value of flags is defined in the DESCRIPTION section. - errfunc
-
Points to a function to be called on error, as defined in the DESCRIPTION section.
- pglob
-
Points to the structure that the caller created. This structure must be passed to
globfree() to release storage allocated byglob() .
RETURN VALUES
If successful, the
- GLOB_ABORTED
-
The scan was stopped because GLOB_ERR was set or (*
errfunc() ) returned non-zero. - GLOB_NOMATCH
-
The pattern does not match any existing path name, and GLOB_NOCHECK was not set in flags.
- GLOB_NOSPACE
-
An attempt to allocate memory failed.
CONFORMANCE
POSIX.2 (1992).
MULTITHREAD SAFETY LEVEL
MT-Safe.
PORTING ISSUES
The GLOB_NOCASE flag was added because file names are case-insensitive on Windows.
AVAILABILITY
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
SEE ALSO
- Functions:
globfree() ,opendir() ,readdir() ,stat()
PTC MKS Toolkit 10.5 Documentation Build 40.