libxdg-basedir-1.2.0  1.2.0
Data Structures | Macros
basedir.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  xdgHandle
 Handle to XDG data cache. More...
 

Macros

#define XDG_BASEDIR_SPEC   0.7
 Version of XDG Base Directory specification implemented in this library.
 

Functions

XDG data cache management
xdgHandlexdgInitHandle (xdgHandle *handle)
 Initialize a handle to an XDG data cache and initialize the cache. More...
 
void xdgWipeHandle (xdgHandle *handle)
 Wipe handle of XDG data cache. More...
 
int xdgUpdateData (xdgHandle *handle)
 Update the data cache. More...
 
Basic XDG Base Directory Queries
const char * xdgDataHome (xdgHandle *handle)
 Base directory for user specific data files. More...
 
const char * xdgConfigHome (xdgHandle *handle)
 Base directory for user specific configuration files. More...
 
const char *const * xdgDataDirectories (xdgHandle *handle)
 Preference-ordered set of base directories to search for data files in addition to the $XDG_DATA_HOME base directory. More...
 
const char *const * xdgSearchableDataDirectories (xdgHandle *handle)
 Preference-ordered set of base directories to search for data files with $XDG_DATA_HOME prepended. More...
 
const char *const * xdgConfigDirectories (xdgHandle *handle)
 Preference-ordered set of base directories to search for configuration files in addition to the $XDG_CONFIG_HOME base directory. More...
 
const char *const * xdgSearchableConfigDirectories (xdgHandle *handle)
 Preference-ordered set of base directories to search for configuration files with $XDG_CONFIG_HOME prepended. More...
 
const char * xdgCacheHome (xdgHandle *handle)
 Base directory for user specific non-essential data files. More...
 
const char * xdgRuntimeDirectory (xdgHandle *handle)
 Base directory for user specific non-essential runtime files such as sockets and named pipes. More...
 

Detailed Description

Functions for using the XDG Base Directory specification.

Definition in file basedir.h.

Function Documentation

◆ xdgCacheHome()

const char* xdgCacheHome ( xdgHandle handle)

Base directory for user specific non-essential data files.

Parameters
handleHandle to data cache, initialized with xdgInitHandle().
Returns
a path as described by the standards.

Definition at line 643 of file basedir.c.

◆ xdgConfigDirectories()

const char* const* xdgConfigDirectories ( xdgHandle handle)

Preference-ordered set of base directories to search for configuration files in addition to the $XDG_CONFIG_HOME base directory.

Parameters
handleHandle to data cache, initialized with xdgInitHandle().
Returns
A null-terminated list of directory strings.

Definition at line 623 of file basedir.c.

◆ xdgConfigHome()

const char* xdgConfigHome ( xdgHandle handle)

Base directory for user specific configuration files.

Parameters
handleHandle to data cache, initialized with xdgInitHandle().
Returns
a path as described by the standards.

Definition at line 596 of file basedir.c.

◆ xdgDataDirectories()

const char* const* xdgDataDirectories ( xdgHandle handle)

Preference-ordered set of base directories to search for data files in addition to the $XDG_DATA_HOME base directory.

Parameters
handleHandle to data cache, initialized with xdgInitHandle().
Returns
A null-terminated list of directory strings.

Definition at line 603 of file basedir.c.

◆ xdgDataHome()

const char* xdgDataHome ( xdgHandle handle)

Base directory for user specific data files.

Parameters
handleHandle to data cache, initialized with xdgInitHandle().
Returns
a path as described by the standards.

Definition at line 589 of file basedir.c.

◆ xdgInitHandle()

xdgHandle* xdgInitHandle ( xdgHandle handle)

Initialize a handle to an XDG data cache and initialize the cache.

Use xdgWipeHandle() to free the handle.

Returns
a pointer to the handle if initialization was successful, else 0

Definition at line 123 of file basedir.c.

◆ xdgRuntimeDirectory()

const char* xdgRuntimeDirectory ( xdgHandle handle)

Base directory for user specific non-essential runtime files such as sockets and named pipes.

Parameters
handleHandle to data cache, initialized with xdgInitHandle().
Returns
a path as described by the standards, or NULL if no path has been set.

Definition at line 650 of file basedir.c.

◆ xdgSearchableConfigDirectories()

const char* const* xdgSearchableConfigDirectories ( xdgHandle handle)

Preference-ordered set of base directories to search for configuration files with $XDG_CONFIG_HOME prepended.

The base directory defined by $XDG_CONFIG_HOME is considered more important than any of the base directories defined by $XDG_CONFIG_DIRS.

Parameters
handleHandle to data cache, initialized with xdgInitHandle().
Returns
A null-terminated list of directory strings.

Definition at line 630 of file basedir.c.

◆ xdgSearchableDataDirectories()

const char* const* xdgSearchableDataDirectories ( xdgHandle handle)

Preference-ordered set of base directories to search for data files with $XDG_DATA_HOME prepended.

The base directory defined by $XDG_DATA_HOME is considered more important than any of the base directories defined by $XDG_DATA_DIRS.

Parameters
handleHandle to data cache, initialized with xdgInitHandle().
Returns
A null-terminated list of directory strings.

Definition at line 610 of file basedir.c.

◆ xdgUpdateData()

int xdgUpdateData ( xdgHandle handle)

Update the data cache.

This should not be done frequently as it reallocates the cache. Even if updating the cache fails the handle remains valid and can be used to access XDG data as it was before xdgUpdateData() was called.

Returns
0 if update failed, non-0 if successful.

Definition at line 414 of file basedir.c.

◆ xdgWipeHandle()

void xdgWipeHandle ( xdgHandle handle)

Wipe handle of XDG data cache.

Wipe handle initialized using xdgInitHandle().

Definition at line 170 of file basedir.c.