API Reference › Os › Os.save_dir
method

Os.save_dir

Os.save_dir(app) -> string

The per-user directory where an application should store save files, named for the app. Which directory that is, is the platform's decision, not the program's:

| | | | --- | --- | | macOS | ~/Library/Application Support/<app> | | Linux | $XDG_DATA_HOME/<app>, or ~/.local/share/<app> |

An XDG variable that is set but empty falls back to the default, as the spec requires. The path is returned as a string; creating the directory and reading/writing files is the filesystem library's job (see the config_dir/cache_dir companions).

On macOS save_dir and config_dir are the same directory — Apple's home for a config file that is not an NSUserDefaults plist is Application Support too. On Linux XDG separates them, and so does this.

Parameters

appthe application name (used as the folder name)

Example

program SaveDir {
  entry {
    let dir = Os.save_dir("MyGame")
    print(len(dir))
  }
}
← All symbols