Mir 1.0
Mir application programming interface
Directory handling routines

Data Structures

struct  mirkl_dir_trctx_t_
 Traverse context. Data in this structure control traversing of directories. More...
 

Macros

#define MIRKL_DIR_TRVRS_NOESCAPE   0x0001
 
#define MIRKL_DIR_TRVRS_PATHNAME   0x0002
 
#define MIRKL_DIR_TRVRS_PERIOD   0x0004
 
#define MIRKL_DIR_TRVRS_CASEINS   0x0008
 
#define MIRKL_DIR_TRVRS_RECURSIVE   0x0010
 
#define MIRKL_DIR_TRVRS_HANDLERERROR   0x0020
 

Typedefs

typedef struct mirkl_dir_trctx_t_ mirkl_dir_trctx_t
 Traverse context. Data in this structure control traversing of directories.
 

Functions

mirkl_error_tmirkl_dir_traverse (const char *dir, const char *inclPtrn, const char *exclPtrn, mirkl_dir_trctx_t *ctx, apr_pool_t *pool)
 Traversing and processing files in directories. More...
 

Detailed Description

Macro Definition Documentation

◆ MIRKL_DIR_TRVRS_CASEINS

#define MIRKL_DIR_TRVRS_CASEINS   0x0008

Compare characters case-insensitively.

◆ MIRKL_DIR_TRVRS_HANDLERERROR

#define MIRKL_DIR_TRVRS_HANDLERERROR   0x0020

Exit on error handler.

◆ MIRKL_DIR_TRVRS_NOESCAPE

#define MIRKL_DIR_TRVRS_NOESCAPE   0x0001

Disable backslash escaping.

◆ MIRKL_DIR_TRVRS_PATHNAME

#define MIRKL_DIR_TRVRS_PATHNAME   0x0002

Slash must be matched by slash.

◆ MIRKL_DIR_TRVRS_PERIOD

#define MIRKL_DIR_TRVRS_PERIOD   0x0004

Period must be matched by period.

◆ MIRKL_DIR_TRVRS_RECURSIVE

#define MIRKL_DIR_TRVRS_RECURSIVE   0x0010

Traverse recursively.

Function Documentation

◆ mirkl_dir_traverse()

mirkl_error_t * mirkl_dir_traverse ( const char *  dir,
const char *  inclPtrn,
const char *  exclPtrn,
mirkl_dir_trctx_t ctx,
apr_pool_t *  pool 
)

Traversing and processing files in directories.

Pattern matching works like in apr_fnmatch(). Here is the copy of APR documentation:

With all flags unset, a pattern is interpreted as such:

PATTERN: Backslash followed by any character, including another backslash.
MATCHES: That character exactly.

PATTERN: ?
MATCHES: Any single character.

PATTERN: *
MATCHES: Any sequence of zero or more characters. (Note that multiple *s in a row are equivalent to one.)

PATTERN: Any character other than \?*[ or a \ at the end of the pattern
MATCHES: That character exactly. (Case sensitive.)

PATTERN: [ followed by a class description followed by ]
MATCHES: A single character described by the class description. (Never matches, if the class description reaches until the end of the string without a ].) If the first character of the class description is ^ or !, the sense of the description is reversed. The rest of the class description is a list of single characters or pairs of characters separated by -. Any of those characters can have a backslash in front of them, which is ignored; this lets you use the characters ] and - in the character class, as well as ^ and ! at the beginning. The pattern matches a single character if it is one of the listed characters or falls into one of the listed ranges (inclusive, case sensitive). Ranges with the first character larger than the second are legal but never match. Edge cases: [] never matches, and [^] and [!] always match without consuming a character.

Note that these patterns attempt to match the entire string, not just find a substring matching the pattern.

Parameters
dirDirectory to traverse.
inclPtrnInclude patterns to match. Several patterns can be defined using ";" as separator.
exclPtrnExclude patterns to match. Several patterns can be defined using ";" as separator.
ctxStructure to control directory parsing. Contains flags field, which is bitwise OR of MIRKL_DIR_TRVRS_...
poolAPR memory pool for temporal allocations.