libcfe  0.12.1
some useful C-functions
check_path_exists.h File Reference
#include <sys/stat.h>
Include dependency graph for check_path_exists.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TYPE_DIR   S_IFDIR
 
#define TYPE_REG   S_IFREG
 
#define TYPE_LNK   S_IFLNK
 
#define TYPE_SOC   S_IFSOCK
 
#define TYPE_FIF   S_IFIFO
 
#define TYPE_CDEV   S_IFCHR
 
#define TYPE_BDEV   S_IFBLK
 
#define TYPE_NONE   0
 
#define TYPE_DEV   (TYPE_BDEV | TYPE_CDEV)
 
#define TYPE_NODIR   (TYPE_REG | TYPE_LNK | TYPE_SOC | TYPE_FIF | TYPE_DEV)
 
#define PATH_R   4
 request read permission More...
 
#define PATH_W   2
 request write permission More...
 
#define PATH_X   1
 request execute permission More...
 
#define PATH_NOCHECK   0
 do not test permission More...
 
#define check_file_exists(file, mode)   check_path_exists(file, S_IFREG, mode)
 
#define check_dir_exists(dir, mode)   check_path_exists(dir, S_IFDIR, mode)
 

Functions

int check_path_exists (const char *path, mode_t type, mode_t mode)
 

Macro Definition Documentation

◆ check_dir_exists

#define check_dir_exists (   dir,
  mode 
)    check_path_exists(dir, S_IFDIR, mode)

Shorthand to check if dir is a directory. See check_path_exists.

Definition at line 33 of file check_path_exists.h.

◆ check_file_exists

#define check_file_exists (   file,
  mode 
)    check_path_exists(file, S_IFREG, mode)

Shorthand to check if file is a regular file. See check_path_exists.

Definition at line 28 of file check_path_exists.h.

◆ PATH_NOCHECK

#define PATH_NOCHECK   0

do not test permission

Definition at line 23 of file check_path_exists.h.

◆ PATH_R

#define PATH_R   4

request read permission

Definition at line 20 of file check_path_exists.h.

◆ PATH_W

#define PATH_W   2

request write permission

Definition at line 21 of file check_path_exists.h.

◆ PATH_X

#define PATH_X   1

request execute permission

Definition at line 22 of file check_path_exists.h.

◆ TYPE_BDEV

#define TYPE_BDEV   S_IFBLK

Definition at line 14 of file check_path_exists.h.

◆ TYPE_CDEV

#define TYPE_CDEV   S_IFCHR

Definition at line 13 of file check_path_exists.h.

◆ TYPE_DEV

#define TYPE_DEV   (TYPE_BDEV | TYPE_CDEV)

Definition at line 16 of file check_path_exists.h.

◆ TYPE_DIR

#define TYPE_DIR   S_IFDIR

Definition at line 7 of file check_path_exists.h.

◆ TYPE_FIF

#define TYPE_FIF   S_IFIFO

Definition at line 12 of file check_path_exists.h.

◆ TYPE_LNK

#define TYPE_LNK   S_IFLNK

Definition at line 9 of file check_path_exists.h.

◆ TYPE_NODIR

#define TYPE_NODIR   (TYPE_REG | TYPE_LNK | TYPE_SOC | TYPE_FIF | TYPE_DEV)

Definition at line 17 of file check_path_exists.h.

◆ TYPE_NONE

#define TYPE_NONE   0

Definition at line 15 of file check_path_exists.h.

◆ TYPE_REG

#define TYPE_REG   S_IFREG

Definition at line 8 of file check_path_exists.h.

◆ TYPE_SOC

#define TYPE_SOC   S_IFSOCK

Definition at line 11 of file check_path_exists.h.

Function Documentation

◆ check_path_exists()

int check_path_exists ( const char *  path,
mode_t  type,
mode_t  mode 
)

Check the existence, type and permissions of a path.

Parameters
[in]pathPointer to a string representing the path.
[in]typeThe type the path should be (0 disables this check).
[in]modeType of access the path should have (0 disables this check).
Returns
return value
  • 0 the path exists and has at least the requested permissions
  • -1 the path does not exists or has not the requested permissions

Definition at line 60 of file check_path_exists.c.

Here is the call graph for this function: