fsautoproc
Basic file transformation automation management utility
Loading...
Searching...
No Matches
fs.c File Reference

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"
Include dependency graph for fs.c:

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.
 

Detailed Description

Filesystem walk and stat implementation.

Function Documentation

◆ 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
fpThe filepath to fstat
sThe struct fsstat_s to populate
Returns
If successful, s is populated and 0 is returned. Otherwise -1 is returned and errno is set.
Here is the caller graph for this function:

◆ fsstateql()

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.

Parameters
aThe first struct fsstat_s to compare
bThe second struct fsstat_s to compare
Returns
Returns true if the two struct fsstat_s values are equal.
Here is the caller graph for this function:

◆ fswalk()

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.

Parameters
dirThe directory to walk
filefnThe 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.
dirfnThe 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.
udataUser 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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fswalkerr()

static int fswalkerr ( const char * epath,
const int errno )
static

Error callback implementation for glob search. Logs each error using the log_error macro.

Parameters
epathThe path that caused the error.
errnoThe error number.
Returns
Always returns 0 to continue the glob scan.
Here is the caller graph for this function: