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

Utility functions for building paths. More...

Go to the source code of this file.


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


enum  gp_mkpath_flags { GP_MKPATH_HAS_FILE = 0x01 }


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.

dirA first directory in path.
...A NULL terminated list of path components.
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


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.

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

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