Name

glob, globfree - generates pathnames matching a pattern.


Library

libc.lib


Synopsis

#include <glob.h>

int glob(const char *pattern, int flags,int(*errfunc)(const char *epath, int eerrno),glob_t *pglob);
void globfree(glob_t *pglob);

Detailed Description

The glob() is a pathname generator function.

The structure type glob_t is defined in the header <glob.h>.

struct glob_t
{
size_t gl_pathc, /* number of paths matched by pattern */
char ** gl_pathv, /* pointer to a list of matched patterns */
size_t gl_offs /* Slots to reserve at the beginning of gl_pathv */
};

The argument pattern is a pointer to a pathname pattern to be expanded. glob() will match all accessible pathnames with the pattern and generates a list of pathnames that match. glob() requires search permission on every component of a path except the last, and read permission on each directory of any filename component of pattern that contains any of the following special characters: '*', '?', and '['.

glob() function will store the number of pathnames that matched in pglob->gl_pathc and a pointer to the matched pathnames in pglob->gl_pathv. The pathnames will be sorted in the order defined by the current setting of LC_COLLATE category.

It is the caller's responsibility to create the structure pointed to by
pglob. The glob() function allocates other space as needed, including the memory pointed to by gl_pathv.

The
globfree() function shall free any space associated with pglob from a previous call to glob().


Return Values

glob() returns 0 on success. The argument pglob->gl_pathc returns the number of matched pathnames and the argument pglob->gl_pathv contains a pointer to a NULL-terminated list of matched and sorted pathnames. If pglob->gl_pathc is 0, the content of pglob->gl_pathv is undefined.

If
glob() terminates because of an error, it returns one of the non-zero constants defined in <glob.h>. The arguments pglob->gl_pathc and pglob->gl_pathv are set as defined above.


Feedback

For additional information or queries on this page send feedback


© 2005-2007 Nokia 

Top