Filesystem walk and stat functions.
More...
#include <stdbool.h>
#include <stdint.h>
Go to the source code of this file.
|
struct | fsstat_s |
| Stat structure for storing the last modified time and file size. More...
|
|
|
typedef int(* | fswalkfn_t) (const char *fp, void *udata) |
| Callback function used by fswalk to process files and directories.
|
|
|
int | fswalk (const char *dir, fswalkfn_t filefn, fswalkfn_t dirfn, void *udata) |
| Recursively walks the single directory described by dir and calls filefn for each file found and dirfn for each directory encountered.
|
|
bool | fsstateql (const struct fsstat_s *a, const struct fsstat_s *b) |
| fsstateql() compares the fields of two struct fsstat_s values for equality. Two structs with the same values are considered equal.
|
|
int | fsstat (const char *fp, struct fsstat_s *s) |
| Populates all fields of a given fsstat_s structure for the file described by the filepath fp .
|
|
Filesystem walk and stat functions.
◆ fswalkfn_t
typedef int(* fswalkfn_t) (const char *fp, void *udata) |
Callback function used by fswalk
to process files and directories.
- Parameters
-
fp | The file or directory path to process |
udata | User data passed to the callback function |
- Returns
- 0 if the walk should continue, otherwise a non-zero value to stop
◆ fsstat()
int fsstat |
( |
const char * | fp, |
|
|
struct fsstat_s * | s ) |
Populates all fields of a given fsstat_s
structure for the file described by the filepath fp
.
- Parameters
-
fp | The filepath to fstat |
s | The struct fsstat_s to populate |
- Returns
- If successful,
s
is populated and 0 is returned. Otherwise -1 is returned and errno
is set.
◆ fsstateql()
fsstateql()
compares the fields of two struct fsstat_s
values for equality. Two structs with the same values are considered equal.
- Parameters
-
- Returns
- Returns true if the two
struct fsstat_s
values are equal.
◆ fswalk()
Recursively walks the single directory described by dir
and calls filefn
for each file found and dirfn
for each directory encountered.
- Parameters
-
dir | The directory to walk |
filefn | The function to call for each file found. The filepath is passed as the first argument. If the function returns a non-zero value, the walk is terminated and the same value is returned by fswalk . |
dirfn | The function to call for each directory found. The directory path is passed as the first argument. If the function returns a non-zero value, the walk is terminated and the same value is returned by fswalk . |
udata | User data to pass to filefn and dirfn |
- Returns
- If successful, 0 is returned. An internal
fswalk
error will return a value of -1 and errno
is set. Otherwise the return value of the first non-zero filefn
or dirfn
call is returned.