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

Filesystem walk and stat functions. More...

#include <stdbool.h>
#include <stdint.h>
Include dependency graph for fs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  fsstat_s
 Stat structure for storing the last modified time and file size. More...
 

Typedefs

typedef int(* fswalkfn_t) (const char *fp, void *udata)
 Callback function used by fswalk to process files and directories.
 

Functions

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 functions.

Typedef Documentation

◆ fswalkfn_t

typedef int(* fswalkfn_t) (const char *fp, void *udata)

Callback function used by fswalk to process files and directories.

Parameters
fpThe file or directory path to process
udataUser data passed to the callback function
Returns
0 if the walk should continue, otherwise a non-zero value to stop

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: