libxdg-basedir-1.0.2  1.0.2
include/basedir_fs.h File Reference

Filesystem functions related to the XDG Base Directory specification. More...

#include <basedir.h>
#include <stdio.h>
#include <sys/types.h>
Include dependency graph for basedir_fs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

Filesystem-related XDG Base Directory Queries
char * xdgDataFind (const char *relativePath, xdgHandle *handle)
 Find all existing data files corresponding to relativePath.
char * xdgConfigFind (const char *relativePath, xdgHandle *handle)
 Find all existing config files corresponding to relativePath.
FILE * xdgDataOpen (const char *relativePath, const char *mode, xdgHandle *handle)
 Open first possible data file corresponding to relativePath.
FILE * xdgConfigOpen (const char *relativePath, const char *mode, xdgHandle *handle)
 Open first possible config file corresponding to relativePath.
int xdgMakePath (const char *path, mode_t mode)
 Create path by recursively creating directories.

Detailed Description

Filesystem functions related to the XDG Base Directory specification.

Definition in file basedir_fs.h.


Function Documentation

char* xdgConfigFind ( const char *  relativePath,
xdgHandle handle 
)

Find all existing config files corresponding to relativePath.

Consider as performing

 fopen(filename, "r") 

on every possible filename and returning the successful filenames.

Parameters:
relativePathPath to scan for.
handleHandle to data cache, initialized with xdgInitHandle().
Returns:
A sequence of null-terminated strings terminated by a double-null (empty string) and allocated using malloc(), e.g.:
 "/etc/xdg\0/home/jdoe/.config\0" 

Definition at line 554 of file basedir.c.

FILE* xdgConfigOpen ( const char *  relativePath,
const char *  mode,
xdgHandle handle 
)

Open first possible config file corresponding to relativePath.

Consider as performing

 fopen(filename, mode) 

on every possible filename and returning the first successful filename or NULL.

Parameters:
relativePathPath to scan for.
modeMode with which to attempt to open files (see fopen modes).
handleHandle to data cache, initialized with xdgInitHandle().
Returns:
File pointer if successful else NULL. Client must use fclose to close file.

Definition at line 562 of file basedir.c.

char* xdgDataFind ( const char *  relativePath,
xdgHandle handle 
)

Find all existing data files corresponding to relativePath.

Consider as performing

 fopen(filename, "r") 

on every possible filename and returning the successful filenames.

Parameters:
relativePathPath to scan for.
handleHandle to data cache, initialized with xdgInitHandle().
Returns:
A sequence of null-terminated strings terminated by a double-null (empty string) and allocated using malloc(), e.g.:
 "/etc/share\0/home/jdoe/.local\0" 

Definition at line 550 of file basedir.c.

FILE* xdgDataOpen ( const char *  relativePath,
const char *  mode,
xdgHandle handle 
)

Open first possible data file corresponding to relativePath.

Consider as performing

 fopen(filename, mode) 

on every possible filename and returning the first successful filename or NULL.

Parameters:
relativePathPath to scan for.
modeMode with which to attempt to open files (see fopen modes).
handleHandle to data cache, initialized with xdgInitHandle().
Returns:
File pointer if successful else NULL. Client must use fclose to close file.

Definition at line 558 of file basedir.c.

int xdgMakePath ( const char *  path,
mode_t  mode 
)

Create path by recursively creating directories.

This utility function is not part of the XDG specification, but nevertheless useful in context of directory manipulation.

Parameters:
pathThe path to be created.
modeThe permissions to use for created directories. This parameter is modified by the process's umask. For details, see mkdir(2)'s mode parameter.
Returns:
Zero on success, -1 if an error occured (in which case errno will be set appropriately)

Definition at line 481 of file basedir.c.