fsautoproc
Basic file transformation automation management utility
|
Filesystem walk and stat implementation. More...
#include "fs.h"
#include <assert.h>
#include <errno.h>
#include <fts.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include "jemalloc/jemalloc.h"
#include "log.h"
Functions | |
static int | fsprocent (FTSENT *ent, fswalkfn_t filefn, void *udata) |
Internal helper function to process a single file entry from the FTS walk. The file's last modified time and size are extracted from the stat structure and passed to the user-defined callback function. | |
int | fswalk (const char *dir, fswalkfn_t filefn, void *udata) |
Recursively walks the single directory described by dir and calls filefn for each file found. | |
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 . | |
char * | fsjoin (const char *dir, const char *file) |
Concatenates the two strings into a single path string, joined by a / (path separator) character. Neither input string is modified or freed. |
Filesystem walk and stat implementation.
char * fsjoin | ( | const char * | dir, |
const char * | file ) |
Concatenates the two strings into a single path string, joined by a / (path separator) character. Neither input string is modified or freed.
dir | The directory path |
file | The file path |
|
static |
Internal helper function to process a single file entry from the FTS walk. The file's last modified time and size are extracted from the stat structure and passed to the user-defined callback function.
ent | The FTSENT file entry to process |
filefn | The user-defined callback function to invoke for the file |
udata | User data pointer to pass to the callback function |
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. int fswalk | ( | const char * | dir, |
fswalkfn_t | filefn, | ||
void * | udata ) |
Recursively walks the single directory described by dir
and calls filefn
for each file found.
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. |
udata | User data to pass to filefn and dirfn |
filefn
or dirfn
call is returned.