Interface Directories
- All Known Implementing Classes:
FakeDirectories
public interface Directories
The base directories where applications store their files, as defined by the XDG Base Directory Specification.
On Linux and other Unix-like systems, each directory comes from its XDG environment variable, or the
specification's default when the variable is unset, empty or not an absolute path. Windows has no such variables: its
directories are computed from the environment variables Windows sets (APPDATA, LOCALAPPDATA,
ProgramData) and fall back to their default locations. macOS uses its standard locations under
~/Library and /Library.
These are base directories, shared by all applications: put files in a subdirectory named after the application. On Windows and macOS several of them are the same directory, so an application that keeps, for example, its cache apart from its state needs distinct subdirectories for them.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the directory for user-specific non-essential, cached data.Returns the system-wide directories to search for configuration files, most important first, afterconfigHome().Returns the directory for user-specific configuration files.dataDirs()Returns the system-wide directories to search for data files, most important first, afterdataHome().dataHome()Returns the directory for user-specific data files.home()Returns the user's home directory.Returns the directory for user-specific runtime files, such as sockets and named pipes.Returns the directory for user-specific state: data that should persist between restarts but is not important or portable enough fordataHome(), such as history, logs or recently used files.
-
Method Details
-
home
Path home()Returns the user's home directory.- Linux, Unix:
$HOME, or theuser.homesystem property if it is unset or not absolute - macOS, Windows: the
user.homesystem property
- Returns:
- the home directory
- Linux, Unix:
-
dataHome
Path dataHome()Returns the directory for user-specific data files.- Linux, Unix:
$XDG_DATA_HOME, default~/.local/share - macOS:
~/Library/Application Support - Windows:
%APPDATA%, default~\AppData\Roaming
- Returns:
- the user data directory
- Linux, Unix:
-
configHome
Path configHome()Returns the directory for user-specific configuration files.- Linux, Unix:
$XDG_CONFIG_HOME, default~/.config - macOS:
~/Library/Application Support - Windows:
%APPDATA%, default~\AppData\Roaming
- Returns:
- the user configuration directory
- Linux, Unix:
-
stateHome
Path stateHome()Returns the directory for user-specific state: data that should persist between restarts but is not important or portable enough fordataHome(), such as history, logs or recently used files.- Linux, Unix:
$XDG_STATE_HOME, default~/.local/state - macOS:
~/Library/Application Support - Windows:
%LOCALAPPDATA%, default~\AppData\Local
- Returns:
- the user state directory
- Linux, Unix:
-
cacheHome
Path cacheHome()Returns the directory for user-specific non-essential, cached data.- Linux, Unix:
$XDG_CACHE_HOME, default~/.cache - macOS:
~/Library/Caches - Windows:
%LOCALAPPDATA%, default~\AppData\Local
- Returns:
- the user cache directory
- Linux, Unix:
-
runtimeDir
Returns the directory for user-specific runtime files, such as sockets and named pipes.- Linux, Unix:
$XDG_RUNTIME_DIR, empty if it is unset; the specification has no default - macOS, Windows: always empty, as there is no equivalent
- Returns:
- the user runtime directory, or empty if there is none
- Linux, Unix:
-
dataDirs
Returns the system-wide directories to search for data files, most important first, afterdataHome().- Linux, Unix:
$XDG_DATA_DIRS, default/usr/local/share:/usr/share - macOS:
/Library/Application Support - Windows:
%ProgramData%, default%SystemDrive%\ProgramData
- Returns:
- the system data directories, in order of importance
- Linux, Unix:
-
configDirs
Returns the system-wide directories to search for configuration files, most important first, afterconfigHome().- Linux, Unix:
$XDG_CONFIG_DIRS, default/etc/xdg - macOS:
/Library/Application Support - Windows:
%ProgramData%, default%SystemDrive%\ProgramData
- Returns:
- the system configuration directories, in order of importance
- Linux, Unix:
-