Skip to content

Commit

Permalink
XDG Base Directory Specification 0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorengarenar committed Apr 27, 2022
1 parent 0e02839 commit 84ab411
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.1.0] - 2022-04-27

Updated to XDG Base Directory Specification version 0.8

### Added

- `XDG_STATE_HOME`

## [1.0.5] - 2022-02-18

### Fixed
Expand Down Expand Up @@ -69,7 +77,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Documentation
- README, CHANGELOG and AUTHORS

[unreleased]: https://github.com/Jorengarenar/libXDGdirs/compare/v1.0.5...HEAD
[unreleased]: https://github.com/Jorengarenar/libXDGdirs/compare/v1.1.0...HEAD
[1.1.0]: https://github.com/Jorengarenar/libXDGdirs/compare/v1.0.5...v1.1.0
[1.0.5]: https://github.com/Jorengarenar/libXDGdirs/compare/v1.0.4...v1.0.5
[1.0.4]: https://github.com/Jorengarenar/libXDGdirs/compare/v1.0.3...v1.0.4
[1.0.3]: https://github.com/Jorengarenar/libXDGdirs/compare/v1.0.2...v1.0.3
Expand Down
8 changes: 8 additions & 0 deletions src/xdgdirs.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ static struct DOXYGEN_UNNAMED {
short initialized;
struct /* user */ {
const char* data; ///< @c $XDG_DATA_HOME
const char* state; ///< @c $XDG_STATE_HOME
const char* config; ///< @c $XDG_CONFIG_HOME
const char* cache; ///< @c $XDG_CACHE_HOME
const char* runtime; ///< @c $XDG_RUNTIME_DIR
Expand All @@ -128,6 +129,7 @@ void xdgDirs_clear()

xdgDirs_free(&xdgDirs_cache.user.config, NULL);
xdgDirs_free(&xdgDirs_cache.user.data, NULL);
xdgDirs_free(&xdgDirs_cache.user.state, NULL);
xdgDirs_free(&xdgDirs_cache.user.cache, NULL);
xdgDirs_free(&xdgDirs_cache.user.runtime, NULL);

Expand All @@ -152,6 +154,7 @@ int xdgDirs_init()
}

xdgDirs_getenv(&xdgDirs_cache.user.data, "XDG_DATA_HOME", "%s%s", home, "/.local/share");
xdgDirs_getenv(&xdgDirs_cache.user.state, "XDG_STATE_HOME", "%s%s", home, "/.local/state");
xdgDirs_getenv(&xdgDirs_cache.user.config, "XDG_CONFIG_HOME", "%s%s", home, "/.config");
xdgDirs_getenv(&xdgDirs_cache.user.cache, "XDG_CACHE_HOME", "%s%s", home, "/.cache");
xdgDirs_getenv(&xdgDirs_cache.user.runtime, "XDG_RUNTIME_DIR", "");
Expand Down Expand Up @@ -193,6 +196,11 @@ const char* xdgDataHome()
XDGDIRS_RETURN(xdgDirs_cache.user.data);
}

const char* xdgStateHome()
{
XDGDIRS_RETURN(xdgDirs_cache.user.state);
}

const char* xdgConfigHome()
{
XDGDIRS_RETURN(xdgDirs_cache.user.config);
Expand Down
11 changes: 9 additions & 2 deletions src/xdgdirs.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ extern "C" {
* @details
* Adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
*/
#define XDGDIRS_VER "1.0.5"
#define XDGDIRS_VER "1.1.0"

/// Version of XDG Base Directory specification implemented in this library
#define XDGBDS_VER "0.7"
#define XDGBDS_VER "0.8"

/// @brief Container for environment variables which are colon separated lists
struct xdgDirsList_t {
Expand Down Expand Up @@ -70,6 +70,13 @@ void xdgDirs_refresh();
*/
const char* xdgDataHome();

/** @brief Value of @c $XDG_STATE_HOME
* @details
* Base directory for user-specific state files
* @return a path as described by the standards or NULL
*/
const char* xdgStateHome();

/** @brief Value of @c $XDG_CONFIG_HOME
* @details
* Base directory for user-specific configuration files (analogous to @c /etc)
Expand Down

0 comments on commit 84ab411

Please sign in to comment.