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 Type
    Method
    Description
    Returns the directory for user-specific non-essential, cached data.
    Returns the system-wide directories to search for configuration files, most important first, after configHome().
    Returns the directory for user-specific configuration files.
    Returns the system-wide directories to search for data files, most important first, after dataHome().
    Returns the directory for user-specific data files.
    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 for dataHome(), such as history, logs or recently used files.
  • Method Details

    • home

      Path home()
      Returns the user's home directory.
      • Linux, Unix: $HOME, or the user.home system property if it is unset or not absolute
      • macOS, Windows: the user.home system property
      Returns:
      the home directory
    • 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
    • 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
    • stateHome

      Path stateHome()
      Returns the directory for user-specific state: data that should persist between restarts but is not important or portable enough for dataHome(), 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
    • 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
    • runtimeDir

      Optional<Path> 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
    • dataDirs

      List<Path> dataDirs()
      Returns the system-wide directories to search for data files, most important first, after dataHome().
      • 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
    • configDirs

      List<Path> configDirs()
      Returns the system-wide directories to search for configuration files, most important first, after configHome().
      • 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