AppDirs.jl

Port of Python `appdirs` to Julia
Author JackDunnNZ
Popularity
1 Star
Updated Last
2 Years Ago
Started In
March 2022

AppDirs

Stable Dev Build Status Coverage

AppDirs.jl is a port of appdirs to Julia. It lets you find the appropriate directory to save caches, logs, and data, on Linux, Mac, and Windows.

Motivation

What directory should your app use for storing user data? If running on Mac OS X, you should use:

~/Library/Application Support/<AppName>

If on Windows that should be:

C:\Users\<username>\AppData\Local\<AppAuthor>\<AppName>

or possibly:

C:\Users\<username>\AppData\Roaming\<AppAuthor>\<AppName>

for roaming profiles but that is another story.

On Linux (and other Unices) the dir, according to the XDG spec (and subject to some interpretation), is either:

~/.config/<AppName>

or possibly:

~/.local/share/<AppName>

Usage

AppDirs.jl will help you choose an appropriate:

  • user data dir (user_data_dir)
  • site data dir (site_data_dir)
  • user config dir (user_config_dir)
  • site config dir (site_config_dir)
  • user cache dir (user_cache_dir)
  • user state dir (user_state_dir)
  • user log dir (user_log_dir)

For example, on Mac:

julia> using AppDirs

julia> appname = "SuperApp"

julia> appauthor = "Acme"

julia> user_data_dir(appname, appauthor)
"/Users/username/Library/Application Support/SuperApp"

julia> site_data_dir(appname, appauthor)
"/Library/Application Support/SuperApp"

julia> user_config_dir(appname, appauthor)
"/Users/username/Library/Preferences/SuperApp"

julia> site_config_dir(appname, appauthor)
"/Library/Preferences/SuperApp"

julia> user_cache_dir(appname, appauthor)
"/Users/username/Library/Caches/SuperApp"

julia> user_state_dir(appname, appauthor)
"/Users/username/Library/Application Support/SuperApp"

julia> user_log_dir(appname, appauthor)
"/Users/username/Library/Logs/SuperApp"