GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
Macros | Enumerations | Functions
gp_path.h File Reference

Utility functions for building paths. More...

Go to the source code of this file.

Macros

#define gp_compose_path(dir, ...)   gp_compose_path_(dir, ##__VA_ARGS__, NULL);
 Builds a path from directories passsed in arguments.
 

Enumerations

enum  gp_mkpath_flags { GP_MKPATH_HAS_FILE = 0x01 }
 

Functions

char * gp_user_home (void)
 Returns a user home directory.
 
int gp_mkpath (const char *base_path, const char *path, enum gp_mkpath_flags flags, int mode)
 Creates a path, if it does not exists.
 

Detailed Description

Utility functions for building paths.

Definition in file gp_path.h.

Macro Definition Documentation

◆ gp_compose_path

#define gp_compose_path (   dir,
  ... 
)    gp_compose_path_(dir, ##__VA_ARGS__, NULL);

Builds a path from directories passsed in arguments.

The returned path is normalized, i.e. there are no two path delimiters '/' next to each other.

Parameters
dirA first directory in path.
...A NULL terminated list of path components.
Returns
A newly allocated buffer with path or NULL in a case of a failure.

Definition at line 38 of file gp_path.h.

Enumeration Type Documentation

◆ gp_mkpath_flags

Enumerator
GP_MKPATH_HAS_FILE 

Last component in path if it does not end with slash is ignored

Definition at line 40 of file gp_path.h.

Function Documentation

◆ gp_mkpath()

int gp_mkpath ( const char *  base_path,
const char *  path,
enum gp_mkpath_flags  flags,
int  mode 
)

Creates a path, if it does not exists.

Works similar to 'mkdir -p'. Hoever if last compoment of the path is a file, i.e. last path component does not end with '/' it's ignored.

Parameters
base_pathA path to create the directories under, can be NULL.
pathA path, one or more directories.
flagsAn enum gp_mkpath_flags.
modeA mode for the directories created in the path.
Returns
Zero on success, non-zero otherwise and errno is set.

◆ gp_user_home()

char * gp_user_home ( void  )

Returns a user home directory.

The home directory is validated to be an absolute path.

Returns
An absolute path to the user home directory or NULL on failure.