applicationConfigHome function

String applicationConfigHome(
  1. String productName
)

Get the user-specific application configuration folder for the current platform.

This is a location appropriate for storing application specific configuration for the current user. The productName should be unique to avoid clashes with other applications on the same machine. This method won't actually create the folder, merely return the recommended location for storing user-specific application configuration.

The folder location depends on the platform:

  • %APPDATA%\<productName> on Windows,
  • $HOME/Library/Application Support/<productName> on Mac OS,
  • $XDG_CONFIG_HOME/<productName> on Linux (if $XDG_CONFIG_HOME is defined), and,
  • $HOME/.config/<productName> otherwise.

This aims follows best practices for each platform, honoring the XDG Base Directory Specification on Linux and File System Basics on Mac OS.

Throws an EnvironmentNotFoundException if %APPDATA% or $HOME is needed but undefined.

Implementation

String applicationConfigHome(String productName) =>
    path.join(_configHome, productName);