Defines | |
#define | PATH_MATCH_DOTFILES 1 |
Functions | |
int | path_merge (str *path, const char *start) |
int | fnmatch (const char *filename, const char *pattern, unsigned options) |
int | has_magic (const char *s) |
int | path_match (const char *pattern, str *result, unsigned options) |
int | path_contains (const char *path, const char *part) |
int | path_mktemp (const char *prefix, str *filename) |
int | path_mkdirs (const char *path, unsigned mode) |
#define PATH_MATCH_DOTFILES 1 |
Make path_match include files starting with dots.
int fnmatch | ( | const char * | filename, | |
const char * | pattern, | |||
unsigned | options | |||
) |
Matches a path using glob patterns.
int has_magic | ( | const char * | s | ) |
Does the string have glob characters in it.
Returns true if the given string contains at least one instance of either *
, ?
, or [
.
int path_contains | ( | const char * | path, | |
const char * | part | |||
) |
Test if a path contains a component.
Returns true if the path
contains part
either at the start followed by a slash, at the end preceded by a slash, or elsewhere with a slash on either side.
int path_match | ( | const char * | pattern, | |
str * | result, | |||
unsigned | options | |||
) |
Matches the pattern against existing files.
This function produces a list of existing files in result
(in the current directory) that match the given pattern. If options
has PATH_MATCH_DOTFILES
set, the result may contain paths starting with ".".
int path_merge | ( | str * | path, | |
const char * | start | |||
) |
Merge two paths together.
This function takes a starting path, and merges the second path into it. If the second path starts with a "/", it replaces the existing path completely. If the second path contains any ".." components, the preceding directory component in the current path (if any) is removed. All "." components are removed.
The effects of this function are equivalent to changing directory to the first path and then using the second one.
int path_mkdirs | ( | const char * | path, | |
unsigned | mode | |||
) |
Create a directory, optionally creating any parent directories.
This function creates the named directory using mkdir
. If any of the parent directories of the specified path do not exist, they are created as well (with the same mode).
int path_mktemp | ( | const char * | prefix, | |
str * | filename | |||
) |
Create a temporary file.
This function creates a temporary file by adding an difficult-to-predict suffix (using the PID and microsecond timestamp) to the given prefix. If this filename does not exist, it is opened in read/write mode.