ExTauri.Paths (ex_tauri v0.2.0)

View Source

Provides platform-appropriate directory paths for desktop applications.

Desktop apps need to store data, configuration, cache, and logs in OS-standard locations. This module resolves the correct paths based on the current platform and the configured :app_name.

Paths by Platform

FunctionmacOSLinuxWindows
data_dir/0~/Library/Application Support/<app>~/.local/share/<app>%APPDATA%/<app>
config_dir/0~/Library/Application Support/<app>~/.config/<app>%APPDATA%/<app>
cache_dir/0~/Library/Caches/<app>~/.cache/<app>%LOCALAPPDATA%/<app>/cache
log_dir/0~/Library/Logs/<app>~/.local/state/<app>/log%LOCALAPPDATA%/<app>/log

All directories are created automatically if they don't exist.

Configuration

config :ex_tauri, :app_name, "My Desktop App"

The app name is normalized to a filesystem-safe identifier (lowercased, spaces replaced with underscores).

Examples

iex> ExTauri.Paths.data_dir()
"/home/user/.local/share/my_desktop_app"

iex> ExTauri.Paths.config_dir()
"/home/user/.config/my_desktop_app"

Summary

Functions

Returns the normalized app name used for directory names.

Returns the platform-appropriate cache directory.

Returns the platform-appropriate configuration directory.

Returns the platform-appropriate data directory for the application.

Returns the platform-appropriate log directory.

Sanitizes a name for safe use in filesystem paths.

Functions

app_identifier()

Returns the normalized app name used for directory names.

Converts the configured :app_name to a filesystem-safe identifier.

cache_dir()

Returns the platform-appropriate cache directory.

Use this for temporary data that can be regenerated. The OS may clear this directory to free disk space.

config_dir()

Returns the platform-appropriate configuration directory.

Use this for user configuration and preferences.

data_dir()

Returns the platform-appropriate data directory for the application.

Use this for persistent application data like databases, user files, etc.

log_dir()

Returns the platform-appropriate log directory.

Use this for application log files.

sanitize_name(name)

Sanitizes a name for safe use in filesystem paths.

Strips path separators and traversal sequences, replaces spaces with underscores, removes any characters that aren't alphanumeric, underscores, or hyphens, and lowercases the result.