Synesis Software

glob() API
[Synesis Software UNIX Emulation for Win32]


Detailed Description

This API provides facilities for enumerating the file-system contents.


Classes

struct  unixem_glob_t
 Result structure for unixem_glob(). More...

Defines

#define GLOB_NOSPACE   (UNIXEM_GLOB_NOSPACE)
#define GLOB_ABORTED   (UNIXEM_GLOB_ABORTED)
#define GLOB_NOMATCH   (UNIXEM_GLOB_NOMATCH)
#define GLOB_NOSYS   (UNIXEM_GLOB_NOSYS)
#define GLOB_ABEND   (UNIXEM_GLOB_ABEND)
#define GLOB_ERR   (UNIXEM_GLOB_ERR)
#define GLOB_MARK   (UNIXEM_GLOB_MARK)
#define GLOB_NOSORT   (UNIXEM_GLOB_NOSORT)
#define GLOB_DOOFFS   (UNIXEM_GLOB_DOOFFS)
#define GLOB_NOCHECK   (UNIXEM_GLOB_NOCHECK)
#define GLOB_APPEND   (UNIXEM_GLOB_APPEND)
#define GLOB_NOESCAPE   (UNIXEM_GLOB_NOESCAPE)
#define GLOB_PERIOD   (UNIXEM_GLOB_PERIOD)
#define GLOB_MAGCHAR   (UNIXEM_GLOB_MAGCHAR)
#define GLOB_NOMAGIC   (UNIXEM_GLOB_NOMAGIC)
#define GLOB_TILDE   (UNIXEM_GLOB_TILDE)
#define GLOB_ONLYDIR   (UNIXEM_GLOB_ONLYDIR)
#define GLOB_TILDE_CHECK   (UNIXEM_GLOB_TILDE_CHECK)
#define GLOB_ONLYFILE   (UNIXEM_GLOB_ONLYFILE)
#define GLOB_NODOTSDIRS   (UNIXEM_GLOB_NODOTSDIRS)
#define GLOB_LIMIT   (UNIXEM_GLOB_LIMIT)
#define UNIXEM_GLOB_NOSPACE   (1)
#define UNIXEM_GLOB_ABORTED   (2)
#define UNIXEM_GLOB_NOMATCH   (3)
#define UNIXEM_GLOB_NOSYS   (4)
#define UNIXEM_GLOB_ABEND   UNIXEM_GLOB_ABORTED
#define UNIXEM_GLOB_ERR   0x00000001
#define UNIXEM_GLOB_MARK   0x00000002
#define UNIXEM_GLOB_NOSORT   0x00000004
#define UNIXEM_GLOB_DOOFFS   0x00000008
#define UNIXEM_GLOB_NOCHECK   0x00000010
#define UNIXEM_GLOB_APPEND   0x00000020
#define UNIXEM_GLOB_NOESCAPE   0x00000040
#define UNIXEM_GLOB_PERIOD   0x00000080
#define UNIXEM_GLOB_MAGCHAR   0x00000100
#define UNIXEM_GLOB_NOMAGIC   0x00000800
#define UNIXEM_GLOB_TILDE   0x00001000
#define UNIXEM_GLOB_ONLYDIR   0x00002000
#define UNIXEM_GLOB_TILDE_CHECK   0x00004000
#define UNIXEM_GLOB_ONLYFILE   0x00008000
#define UNIXEM_GLOB_NODOTSDIRS   0x00010000
#define UNIXEM_GLOB_LIMIT   0x00020000

Typedefs

typedef unixem_glob_t glob_t
 Result structure for glob().

Functions

int glob (char const *pattern, int flags, const int(*errfunc)(char const *, int), glob_t *pglob)
 Generates pathnames matching a pattern.
void globfree (glob_t *pglob)
 Frees the results of a call to glob.
int unixem_glob (char const *pattern, int flags, const int(*errfunc)(char const *, int), unixem_glob_t *pglob)
 Generates pathnames matching a pattern.
void unixem_globfree (unixem_glob_t *pglob)
 Frees the results of a call to unixem_glob().


Define Documentation

#define GLOB_ABEND   (UNIXEM_GLOB_ABEND)

(Error result code:) .

#define GLOB_ABORTED   (UNIXEM_GLOB_ABORTED)

(Error result code:) The scan was stopped because an error was encountered and either GLOB_ERR was set or (*errfunc)() returned non-zero.

#define GLOB_APPEND   (UNIXEM_GLOB_APPEND)

Append to results of a previous call. Not currently supported in this implementation.

#define GLOB_DOOFFS   (UNIXEM_GLOB_DOOFFS)

Insert PGLOB->gl_offs NULLs. Supported from version 1.6 of UNIXem.

#define GLOB_ERR   (UNIXEM_GLOB_ERR)

Return on read errors.

#define GLOB_LIMIT   (UNIXEM_GLOB_LIMIT)

Limits the search to the number specified by the caller in gl_matchc. Supported from version 1.6 of UNIXem.

#define GLOB_MAGCHAR   (UNIXEM_GLOB_MAGCHAR)

Set in gl_flags if any metachars seen. Supported from version 1.6 of UNIXem.

#define GLOB_MARK   (UNIXEM_GLOB_MARK)

Append a slash to each name.

#define GLOB_NOCHECK   (UNIXEM_GLOB_NOCHECK)

If nothing matches, return the pattern. Supported from version 1.6 of UNIXem.

#define GLOB_NODOTSDIRS   (UNIXEM_GLOB_NODOTSDIRS)

Elide "." and ".." directories from wildcard searches. Supported from version 1.6 of UNIXem.

#define GLOB_NOESCAPE   (UNIXEM_GLOB_NOESCAPE)

Backslashes don't quote metacharacters. Has no effect in this implementation, since escaping is not supported.

#define GLOB_NOMAGIC   (UNIXEM_GLOB_NOMAGIC)

< Use gl_opendir et al functions. Not currently supported in this implementation.

< Expand "{a,b}" to "a" "b". Not currently supported in this implementation. If no magic chars, return the pattern. Supported from version 1.6 of UNIXem.

#define GLOB_NOMATCH   (UNIXEM_GLOB_NOMATCH)

(Error result code:) The pattern does not match any existing pathname, and GLOB_NOCHECK was not set int flags.

#define GLOB_NOSORT   (UNIXEM_GLOB_NOSORT)

Don't sort the names.

#define GLOB_NOSPACE   (UNIXEM_GLOB_NOSPACE)

(Error result code:) An attempt to allocate memory failed, or if errno was 0 GLOB_LIMIT was specified in the flags and ARG_MAX patterns were matched.

#define GLOB_NOSYS   (UNIXEM_GLOB_NOSYS)

(Error result code:) .

#define GLOB_ONLYDIR   (UNIXEM_GLOB_ONLYDIR)

Match only directories. This implementation guarantees to only return directories when this flag is specified.

#define GLOB_ONLYFILE   (UNIXEM_GLOB_ONLYFILE)

Match only files. Supported from version 1.6 of UNIXem.

#define GLOB_PERIOD   (UNIXEM_GLOB_PERIOD)

Leading `.' can be matched by metachars. Supported from version 1.6 of UNIXem.

#define GLOB_TILDE   (UNIXEM_GLOB_TILDE)

Expand ~user and ~ to home directories. Partially supported from version 1.6 of UNIXem: leading ~ is expanded to HOMEDRIVE%HOMEPATH%.

#define GLOB_TILDE_CHECK   (UNIXEM_GLOB_TILDE_CHECK)

Like GLOB_TILDE but return an GLOB_NOMATCH even if GLOB_NOCHECK specified. Supported from version 1.6 of UNIXem.

#define UNIXEM_GLOB_ABEND   UNIXEM_GLOB_ABORTED

(Error result code:) .

#define UNIXEM_GLOB_ABORTED   (2)

(Error result code:) The scan was stopped because an error was encountered and either UNIXEM_GLOB_ERR was set or (*errfunc)() returned non-zero.

#define UNIXEM_GLOB_APPEND   0x00000020

Append to results of a previous call. Not currently supported in this implementation.

#define UNIXEM_GLOB_DOOFFS   0x00000008

Insert PGLOB->gl_offs NULLs. Supported from version 1.6 of UNIXem.

Referenced by unixem_glob().

#define UNIXEM_GLOB_ERR   0x00000001

Return on read errors.

#define UNIXEM_GLOB_LIMIT   0x00020000

Limits the search to the number specified by the caller in gl_matchc. Supported from version 1.6 of UNIXem.

Referenced by unixem_glob().

#define UNIXEM_GLOB_MAGCHAR   0x00000100

Set in gl_flags if any metachars seen. Supported from version 1.6 of UNIXem.

Referenced by unixem_glob().

#define UNIXEM_GLOB_MARK   0x00000002

Append a slash to each name.

Referenced by unixem_glob().

#define UNIXEM_GLOB_NOCHECK   0x00000010

If nothing matches, return the pattern. Supported from version 1.6 of UNIXem.

Referenced by unixem_glob().

#define UNIXEM_GLOB_NODOTSDIRS   0x00010000

Elide "." and ".." directories from wildcard searches. Supported from version 1.6 of UNIXem.

Referenced by unixem_glob().

#define UNIXEM_GLOB_NOESCAPE   0x00000040

Backslashes don't quote metacharacters. Has no effect in this implementation, since escaping is not supported.

#define UNIXEM_GLOB_NOMAGIC   0x00000800

< Use gl_opendir et al functions. Not currently supported in this implementation.

< Expand "{a,b}" to "a" "b". Not currently supported in this implementation. If no magic chars, return the pattern. Supported from version 1.6 of UNIXem.

Referenced by unixem_glob().

#define UNIXEM_GLOB_NOMATCH   (3)

(Error result code:) The pattern does not match any existing pathname, and UNIXEM_GLOB_NOCHECK was not set int flags.

Referenced by unixem_glob().

#define UNIXEM_GLOB_NOSORT   0x00000004

Don't sort the names.

Referenced by unixem_glob().

#define UNIXEM_GLOB_NOSPACE   (1)

(Error result code:) An attempt to allocate memory failed, or if errno was 0 UNIXEM_GLOB_LIMIT was specified in the flags and ARG_MAX patterns were matched.

Referenced by unixem_glob().

#define UNIXEM_GLOB_NOSYS   (4)

(Error result code:) .

#define UNIXEM_GLOB_ONLYDIR   0x00002000

Match only directories. This implementation guarantees to only return directories when this flag is specified.

Referenced by unixem_glob().

#define UNIXEM_GLOB_ONLYFILE   0x00008000

Match only files. Supported from version 1.6 of UNIXem.

Referenced by unixem_glob().

#define UNIXEM_GLOB_PERIOD   0x00000080

Leading `.' can be matched by metachars. Supported from version 1.6 of UNIXem.

Referenced by unixem_glob().

#define UNIXEM_GLOB_TILDE   0x00001000

Expand ~user and ~ to home directories. Partially supported from version 1.6 of UNIXem: leading ~ is expanded to HOMEDRIVE%HOMEPATH%.

Referenced by unixem_glob().

#define UNIXEM_GLOB_TILDE_CHECK   0x00004000

Like UNIXEM_GLOB_TILDE but return an UNIXEM_GLOB_NOMATCH even if UNIXEM_GLOB_NOCHECK specified. Supported from version 1.6 of UNIXem.

Referenced by unixem_glob().


Typedef Documentation

Result structure for glob().

This structure is used by glob() to return the results of the search.


Function Documentation

int glob ( char const *  pattern,
int  flags,
const int(*)(char const *, int)  errfunc,
glob_t pglob 
)

Generates pathnames matching a pattern.

This function is a pathname generator that implements the rules for file name pattern matching used by the UNIX shell.

Parameters:
pattern The pattern controlling the search
flags A combination of the GLOB_* flags
errfunc A function that is called each time part of the search processing fails
pglob Pointer to a glob_t structure to receive the search results
Returns:
0 on success, otherwise one of the GLOB_* error codes
Note:
This is a macro, which resolves to unixem_glob()

void globfree ( glob_t pglob  ) 

Frees the results of a call to glob.

This function releases any memory allocated in a call to glob. It must always be called for a successful call to glob.

Parameters:
pglob Pointer to a glob_t structure to receive the search results
Note:
This is a macro, which resolves to unixem_globfree()

int unixem_glob ( char const *  pattern,
int  flags,
const int(*)(char const *, int)  errfunc,
unixem_glob_t pglob 
)

Generates pathnames matching a pattern.

This function is a pathname generator that implements the rules for file name pattern matching used by the UNIX shell.

Parameters:
pattern The pattern controlling the search
flags A combination of the UNIXEM_GLOB_* flags
errfunc A function that is called each time part of the search processing fails
pglob Pointer to a glob_t structure to receive the search results
Returns:
0 on success, otherwise one of the UNIXEM_GLOB_* error codes

References unixem_glob_t::gl_flags, unixem_glob_t::gl_matchc, unixem_glob_t::gl_offs, unixem_glob_t::gl_pathc, unixem_glob_t::gl_pathv, NUM_ELEMENTS, UNIXEM_GLOB_DOOFFS, UNIXEM_GLOB_LIMIT, UNIXEM_GLOB_MAGCHAR, UNIXEM_GLOB_MARK, UNIXEM_GLOB_NOCHECK, UNIXEM_GLOB_NODOTSDIRS, UNIXEM_GLOB_NOMAGIC, UNIXEM_GLOB_NOMATCH, UNIXEM_GLOB_NOSORT, UNIXEM_GLOB_NOSPACE, UNIXEM_GLOB_ONLYDIR, UNIXEM_GLOB_ONLYFILE, UNIXEM_GLOB_PERIOD, UNIXEM_GLOB_TILDE, and UNIXEM_GLOB_TILDE_CHECK.

void unixem_globfree ( unixem_glob_t pglob  ) 

Frees the results of a call to unixem_glob().

This function releases any memory allocated in a call to unixem_glob(). It must always be called for a successful call to unixem_glob().

Parameters:
pglob Pointer to a glob_t structure to receive the search results

References unixem_glob_t::gl_pathc, and unixem_glob_t::gl_pathv.


UNIX Emulation for Win32 Libraries documentation © Synesis Software Pty Ltd, 2002-2010