GRU - Generic Reusable Utilities
Functions
gru_path.c File Reference
#include "gru_path.h"
#include "common/gru_alloc.h"

Functions

bool gru_path_exists (const char *filename, gru_status_t *status)
 Checks whether a given file exists. More...
 
bool gru_path_fexists (int fd, gru_status_t *status)
 Checks whether a given file exists based on it's file descriptor. More...
 
bool gru_path_can_read_write (const char *filename, gru_status_t *status)
 Checks whether can read/write a given file. More...
 
bool gru_path_rename_cond (const char *filename, gru_path_cond_t cond, gru_status_t *status)
 Renames a file based on a condition. More...
 
bool gru_path_rename (const char *filename, gru_status_t *status)
 Renames a file. More...
 
char * gru_path_format (const char *dir, const char *name, gru_status_t *status)
 Formats a path. More...
 
bool gru_path_mkdir (const char *path, gru_status_t *status)
 Create a directory. More...
 
bool gru_path_mkdirs (const char *path, gru_status_t *status)
 Given a path, this function will recursively create directories. More...
 

Function Documentation

◆ gru_path_can_read_write()

bool gru_path_can_read_write ( const char *  filename,
gru_status_t status 
)

Checks whether can read/write a given file.

Parameters
filenamethe filename
statusstatus structure containing error code/description in case of failure
Returns

◆ gru_path_exists()

bool gru_path_exists ( const char *  filename,
gru_status_t status 
)

Checks whether a given file exists.

Parameters
filenamethe filename
statusstatus structure containing error code/description in case of failure
Returns

◆ gru_path_fexists()

bool gru_path_fexists ( int  fd,
gru_status_t status 
)

Checks whether a given file exists based on it's file descriptor.

Parameters
fdthe file descriptor
statusstatus structure containing error code/description in case of failure
Returns
Examples
config/gru_config_test.c.

◆ gru_path_format()

char* gru_path_format ( const char *  dir,
const char *  name,
gru_status_t status 
)

Formats a path.

Parameters
dirdirectory of the file
namename of the file
statusstatus structure containing error code/description in case of failure
Returns
the formatted path

◆ gru_path_mkdir()

bool gru_path_mkdir ( const char *  path,
gru_status_t status 
)

Create a directory.

Callers should beware of potential race conditions.

Parameters
pathdirectory path
statusstatus structure containing error code/description in case of failure
Returns
true if successful or false otherwise

◆ gru_path_mkdirs()

bool gru_path_mkdirs ( const char *  path,
gru_status_t status 
)

Given a path, this function will recursively create directories.

Parameters
pathThe path
statusstatus structure containing error code/description in case of failure
Returns
true if successfully create the directories or false otherwise

◆ gru_path_rename()

bool gru_path_rename ( const char *  filename,
gru_status_t status 
)

Renames a file.

Parameters
filenamethe filename
statusstatus structure containing error code/description in case of failure
Returns
true if successful or false otherwise

◆ gru_path_rename_cond()

bool gru_path_rename_cond ( const char *  filename,
gru_path_cond_t  cond,
gru_status_t status 
)

Renames a file based on a condition.

Parameters
filenamethe filename
condcondition that must be fulfilled for the rename to occur
statusstatus structure containing error code/description in case of failure
Returns
true if successful or false otherwise