fsautoproc
Basic file transformation automation management utility
|
Filesystem walk and stat implementation. More...
#include "fs.h"
#include <assert.h>
#include <glob.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include "log.h"
Functions | |
static int | fswalkerr (const char *epath, const int errno) |
Error callback implementation for glob search. Logs each error using the log_error macro. | |
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 implementation.
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
.
fp | The filepath to fstat |
s | The struct fsstat_s to populate |
s
is populated and 0 is returned. Otherwise -1 is returned and errno
is set. fsstateql()
compares the fields of two struct fsstat_s
values for equality. Two structs with the same values are considered equal.
struct fsstat_s
values are equal. 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.
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 |
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.
|
static |
Error callback implementation for glob search. Logs each error using the log_error
macro.
epath | The path that caused the error. |
errno | The error number. |