class XdgBaseDirectory::XdgDirs

Overview

XdgDirs is a helper class to quickly access all the xdg-directories for a certain application.

Usage:

xdg_dirs = XdgDirs.new("my-awesome-app")
settings = xdg_dirs.config.read_file("settings.ini")
# ...

Defined in:

xdg_base_directory/xdg_dirs.cr

Constructors

Instance Method Summary

Macro Summary

Constructor Detail

def self.new(*subdirs : String) #

This class assumes that all files live in subdirectories of the XDG base dirs.


[View source]

Instance Method Detail

def all_config_dirs #

xdg_config_home + xdg_config_dirs as XdgDirs

The order of base directories denotes their importance; the first directory listed is the most important. When the same information is defined in multiple places the information defined relative to the more important base directory takes precedent. The base directory defined by $XDG_DATA_HOME is considered more important than any of the base directories defined by $XDG_DATA_DIRS. The base directory defined by $XDG_CONFIG_HOME is considered more important than any of the base directories defined by $XDG_CONFIG_DIRS.


[View source]
def all_data_dirs #

xdg_data_home + xdg_data_dirs as XdgDirs

The order of base directories denotes their importance; the first directory listed is the most important. When the same information is defined in multiple places the information defined relative to the more important base directory takes precedent. The base directory defined by $XDG_DATA_HOME is considered more important than any of the base directories defined by $XDG_DATA_DIRS. The base directory defined by $XDG_CONFIG_HOME is considered more important than any of the base directories defined by $XDG_CONFIG_DIRS.


[View source]
def cache #

A directory to which user-specific non-essential (cached) data should be written.


[View source]
def config #

A directory to which user-specific configuration files should be written.


[View source]
def config_files(filename) #

Look up configuration files by filename in all config dirs in order of importance.

A specification that refers to $XDG_DATA_DIRS or $XDG_CONFIG_DIRS should define what the behaviour must be when a file is located under multiple base directories. It could, for example, define that only the file under the most important base directory should be used or, as another example, it could define rules for merging the information from the different files.


[View source]
def data #

A directory to which user-specific data files should be written.


[View source]
def data_files(filename) #

Look up data files by filename in all data dirs in order of importance.

A specification that refers to $XDG_DATA_DIRS or $XDG_CONFIG_DIRS should define what the behaviour must be when a file is located under multiple base directories. It could, for example, define that only the file under the most important base directory should be used or, as another example, it could define rules for merging the information from the different files.


[View source]
def runtime_dir #

A directory in which user-specific runtime files and other file objects should be placed.


[View source]
def state #

state data that should persist between (application) restarts, but that is not important or portable enough to the user that it should be stored in data_home


[View source]

Macro Detail

macro def_xdg_dir(name, method_name = "") #

define a method to return the specified XdgDir for this application.


[View source]