Small XDG base directory library

Mark Nevill mark.nevill at
Tue Feb 27 15:12:15 PST 2007

I have written a small library that implements the XDG base directory
specification (0.6). I wrote it because there seemed to be nothing
other than including a mega-library like Glib or Qt to get at these
simple specifications without re-writing them for every application
that doesn't need the other 99% of the functionality provided by said
massive libraries. The library is written in C and is documented using
doxygen. Two small programs are built for testing (and are useful as
usage examples) although I have not written any automatic tests (but I
have tested manually). I have uploaded a source tarball (
) as generated by autotools, and appended a synopsis of the header to
this email. The functions xdgDataOpen and xdgConfigOpen are untested,
the rest should function as documented. I'm wondering whether there is
any interest in such a library (and possibly other small libraries of
similar nature) and feedback for possible improvements.
Mark Nevill

Header Synopsis:

#define XDG_BASEDIR_SPEC 0.6

typedef struct _xdgHandle {
    void *reserved;
} *xdgHandle;
xdgHandle xdgAllocHandle();
void xdgFreeHandle(xdgHandle handle);
bool xdgUpdateData(xdgHandle handle);

const char * xdgDataHome(xdgHandle handle);
const char * xdgConfigHome(xdgHandle handle);
const char * const * xdgDataDirectories(xdgHandle handle);
const char * const * xdgSearchableDataDirectories(xdgHandle handle);
const char * const * xdgConfigDirectories(xdgHandle handle);
const char * const * xdgSearchableConfigDirectories(xdgHandle handle);
const char * xdgCacheHome(xdgHandle handle);

const char * xdgDataFind(const char* relativePath, xdgHandle handle);
const char * xdgConfigFind(const char* relativePath, xdgHandle handle);
FILE * xdgDataOpen(const char* relativePath, const char* mode,
xdgHandle handle);
FILE * xdgConfigOpen(const char* relativePath, const char* mode,
xdgHandle handle);

More information about the xdg mailing list