diff --git a/xdg/basedir/README b/xdg/basedir/README new file mode 100644 index 0000000..f795304 --- /dev/null +++ b/xdg/basedir/README @@ -0,0 +1,2 @@ +The basedir module implements the XDG Base Directory Specification as described +in (https://specifications.freedesktop.org/basedir-spec/latest/). diff --git a/xdg/basedir/basedir.ha b/xdg/basedir/basedir.ha new file mode 100644 index 0000000..8ee44a3 --- /dev/null +++ b/xdg/basedir/basedir.ha @@ -0,0 +1,98 @@ +// Returns the single base directory relative to which user-specific data files +// should be written, which is defined by $XDG_DATA_HOME. If $XDG_DATA_HOME is +// either not set or empty, a default equal to $HOME/.local/share is used. +// +// The memory is statically allocated and must not be free'd. It may be +// overwritten later, so use [[strings::dup]] to extend its lifetime. +export fn data_home (prog: str = "") str = { + // TODO +}; + +// Returns the single base directory relative to which user-specific +// configuration files should be written, which is defined by $XDG_CONFIG_HOME. +// If $XDG_CONFIG_HOME is either not set or empty, a default equal to +// $HOME/.config is used. +// +// The memory is statically allocated and must not be free'd. It may be +// overwritten later, so use [[strings::dup]] to extend its lifetime.s +export fn config_home (prog: str = "") str = { + // TODO +}; + +// Returns the single base directory relative to which user-specific state data +// that should persist between (application) restarts, but that is not important +// or portable enough to the user that it should be stored. It is defined by +// $XDG_STATE_HOME. It may contain: +// +// - actions history (logs, history, recently used files, …) +// - current state of the application that can be reused on a restart (view, +// layout, open files, undo history, …) +// +// The memory is statically allocated and must not be free'd. It may be +// overwritten later, so use [[strings::dup]] to extend its lifetime. +export fn state_home (prog: str = "") str = { + // TODO +}; + +// CacheHome returns the single base directory relative to which user-specific +// non-essential (cached) data should be written, which is defined by +// $XDG_CACHE_HOME. If $XDG_CACHE_HOME is either not set or empty, a default +// equal to $HOME/.cache is used. +// +// The memory is statically allocated and must not be free'd. It may be +// overwritten later, so use [[strings::dup]] to extend its lifetime. +export fn cache_home (prog: str = "") str = { + // TODO +}; + +// Returns the single base directory relative to which user-specific runtime +// files and other file objects should be placed, which is defined by +// $XDG_RUNTIME_DIR. This module does not provide a fallback directory. If this +// function returns an error, applications should fall back to a replacement +// directory with similar capabilities (in accordance with §3) and print a +// warning message. +// +// The memory is statically allocated and must not be free'd. It may be +// overwritten later, so use [[strings::dup]] to extend its lifetime. +export fn runtime_dir (prog: str = "") str = { + // TODO +}; + +// Returns the set of preference ordered base directories relative to which data +// files should be searched, which is defined by $XDG_DATA_DIRS. If +// $XDG_DATA_DIRS is either not set or empty, a value equal to +// /usr/local/share/:/usr/share/ is used. It is reccomended to call [[data_all]] +// instead for most use cases. +// +// The memory is statically allocated and must not be free'd. It may be +// overwritten later, so use [[strings::dup]] to extend its lifetime. +export fn data_dirs (prog: str = "") []str = { + // TODO +}; + +// Returns set of preference ordered base directories relative to which +// configuration files should be searched, which is defined by $XDG_CONFIG_DIRS. +// If $XDG_CONFIG_DIRS is either not set or empty, a value equal to /etc/xdg is +// used. It is reccomended to call [[config_all]] instead for most use cases. +// +// The memory is statically allocated and must not be free'd. It may be +// overwritten later, so use [[strings::dup]] to extend its lifetime. +export fn config_dirs (prog: str = "") []str = { + // TODO +}; + +// Returns the result of [[data_home]] in front of [[data_dirs]]. +// +// The memory is statically allocated and must not be free'd. It may be +// overwritten later, so use [[strings::dup]] to extend its lifetime. +export fn data_all (prog: str = "") []str = { + // TODO +}; + +// Returns the result of [[config_home]] in front of [[config_dirs]]. +// +// The memory is statically allocated and must not be free'd. It may be +// overwritten later, so use [[strings::dup]] to extend its lifetime. +export fn config_all (prog: str = "") []str = { + // TODO +};