clsync
Macros | Functions
fileutils.c File Reference
#include "common.h"
#include "error.h"
#include "malloc.h"
Include dependency graph for fileutils.c:

Go to the source code of this file.

Macros

#define STAT_COMPARE(bit, field)
 

Functions

char * fd2fpath_malloc (int fd)
 
int fileutils_copy (const char *path_from, const char *path_to)
 Copies file. More...
 
short int fileutils_calcdirlevel (const char *path)
 Calculates directory level of a canonized path (actually it just counts "/"-s) More...
 
int mkdirat_open (const char *const dir_path, int dirfd_parent, mode_t dir_mode)
 Combination of mkdirat() and openat() More...
 
uint32_t stat_diff (stat64_t *a, stat64_t *b)
 

Macro Definition Documentation

◆ STAT_COMPARE

#define STAT_COMPARE (   bit,
  field 
)
Value:
if (a->field != b->field) \
difference |= bit;

Function Documentation

◆ fd2fpath_malloc()

char* fd2fpath_malloc ( int  fd)

Definition at line 26 of file fileutils.c.

◆ fileutils_calcdirlevel()

short int fileutils_calcdirlevel ( const char *  path)

Calculates directory level of a canonized path (actually it just counts "/"-s)

Parameters
[in]pathCanonized path (with realpath())
Return values
zeroor prositive Direcory level
negativeGot error, while calculation. Error-code is placed to errno.

Definition at line 138 of file fileutils.c.

◆ fileutils_copy()

int fileutils_copy ( const char *  path_from,
const char *  path_to 
)

Copies file.

Parameters
[in]path_fromSource file path
[in]path_toDestination file path
Return values
zeroSuccessfully copied
non-zeroGot error, while copying

Definition at line 78 of file fileutils.c.

Here is the caller graph for this function:

◆ mkdirat_open()

int mkdirat_open ( const char *const  dir_path,
int  dirfd_parent,
mode_t  dir_mode 
)

Combination of mkdirat() and openat()

Parameters
[in]dir_pathPath to directory to create and open
[in]dirfd_parentFile descriptor of directory for relative paths
[in]dir_modeModes for newly created directory (e.g. 750)
Return values
dirfdFile descriptor to newly created directory
NULLOn error

Definition at line 179 of file fileutils.c.

◆ stat_diff()

uint32_t stat_diff ( stat64_t a,
stat64_t b 
)

Definition at line 219 of file fileutils.c.