char **karray_dirlist(
char *basename,
char *global_dir,
char *filter,
int list_mode,
int format,
size_t *num)
The 'global_dir' parameter specifies the directory path to use for creating of the string array. This directory path may include toolbox names (for example, $BOOTSTRAP) or tildas (for example, ~fred). Passing NULL implies that the 'basename' parameter will be used to specify the directory.
The 'basename' parameter allows you to specify a set of letters which must be matched by the entries in the directory before they are included in the resulting array. For example, providing "img" as the basename will cause only those entries in the directory beginning with the letters "img" to be included in the array. Passing NULL indicates that ALL entries in the directory specified by 'global_dir' are acceptable for inclusion in the array (unless otherwise specified using the 'filter' parameter).
For your convenience, the values of both the 'global_dir' and the 'basename' parameters may be combined into the value of the 'basename' parameter. For example, if you wanted to create the string array from all entries in the ~fred/data directory beginning with the letters "d3", then you could pass "~fred/data/d3" as the 'basename' and NULL as the 'global_dir'.
More powerful and flexible than the 'basename' parameter, as well as more difficult to use, the 'filter' parameter allows you to specify a more complicated filter that entries in the directory must match before they are included in the array. The regular expression syntax is used to specify the filter; see kre_comp() for the syntax required to specify the desired pattern matching.
The 'list_mode' parameter indicates which entries in the directory are to be included in the resulting array of strings. The following list modes are supported:
KPATH - prepend the path to each file KFILE - list plain text files KDIR - list subdirectories KDOT - list dot files KLINK - list symbolic files KSOCK - list socket files KREAD - file is readable by caller KWRITE - file is writable by caller KEXEC - file is executable by caller KRECURSE - recursively list all subdirectories
The list modes may be or'ed together in order to specify the entries in the directory that should be included in the string array produced. For example, "KFILE | KDIR" will cause the resulting string array to have entries for will list only files and directories.
none
none
$BOOTSTRAP/objects/library/kutils/src/array.c