libamxp
1.4.0
Patterns C Implementation
|
Typedefs | |
typedef int(* | amxp_dir_match_fn_t) (const char *name, void *priv) |
Matching file/directory callback function signature. More... | |
Functions | |
int | amxp_dir_make (const char *path, const mode_t mode) |
Creates sub-directories. More... | |
int | amxp_dir_owned_make (const char *path, const mode_t mode, uid_t uid, gid_t gid) |
Creates sub-directories and changes ownership. More... | |
int | amxp_dir_scan (const char *path, const char *filter, bool recursive, amxp_dir_match_fn_t fn, void *priv) |
Scans a directory and calls a callback function for each matching entry found. More... | |
bool | amxp_dir_is_empty (const char *path) |
Checks if a directory is empty. More... | |
bool | amxp_dir_is_directory (const char *path) |
Checks if a path is a directory. More... | |
File system directory utilities and helper functions
typedef int(* amxp_dir_match_fn_t) (const char *name, void *priv) |
Matching file/directory callback function signature.
The amxp_dir_scan function will call the callback function for each matching file or directory found.
name | full path of the matching file or directory |
priv | a pointer to some data, provided to amxp_dir_scan |
Definition at line 96 of file amxp_dir.h.
bool amxp_dir_is_directory | ( | const char * | path | ) |
Checks if a path is a directory.
path | relative or absolute path to a file or directory |
Definition at line 257 of file amxp_dir.c.
bool amxp_dir_is_empty | ( | const char * | path | ) |
Checks if a directory is empty.
A directory is considered empty when it doesn't contain any file or sub-directory.
if the given path doesn't exist or is not a directory this function will return true.
path | relative or absolute path to a directory that needs to be scanned |
Definition at line 243 of file amxp_dir.c.
int amxp_dir_make | ( | const char * | path, |
const mode_t | mode | ||
) |
Creates sub-directories.
This function will create all sub-directories, if not existing yet.
If the path provided contains intermediate sub-directories that don't exist, they will be created.
path | relative or absolute path to sub-directories that needs to be created |
mode | the argument mode specifies the permissions to use |
Definition at line 212 of file amxp_dir.c.
int amxp_dir_owned_make | ( | const char * | path, |
const mode_t | mode, | ||
uid_t | uid, | ||
gid_t | gid | ||
) |
Creates sub-directories and changes ownership.
This function will create all sub-directories, if not existing yet.
When a (sub)directory is created and the given user id and group id are not 0, ownership is changed and set to the given user id and group id.
path | relative or absolute path to sub-directories that needs to be created |
mode | the argument mode specifies the permissions to use |
uid | a user id |
gid | a group id |
Definition at line 156 of file amxp_dir.c.
int amxp_dir_scan | ( | const char * | path, |
const char * | filter, | ||
bool | recursive, | ||
amxp_dir_match_fn_t | fn, | ||
void * | priv | ||
) |
Scans a directory and calls a callback function for each matching entry found.
When no filter is provided, all found entries are considered a match.
The filter works on the directory entry data. The fields that can be used are:
When the argument recursive is set to true, the scan will enter all found directories and scan these as well.
Filter examples:
path | relative or absolute path to a directory that needs to be scanned |
filter | (optional) an expression that can be used to filter to directory entries |
recursive | when set to true all found sub-directories will be scanned as well. |
fn | callback function which is called for each matching entry |
priv | some private data, will be passed to the callback function |
Definition at line 216 of file amxp_dir.c.