diff -Nru rust-directories-2.0.1/Cargo.toml rust-directories-4.0.1/Cargo.toml --- rust-directories-2.0.1/Cargo.toml 1970-01-01 00:00:00.000000000 +0000 +++ rust-directories-4.0.1/Cargo.toml 1970-01-01 00:00:00.000000000 +0000 @@ -3,7 +3,7 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g. crates.io) dependencies +# to registry (e.g., crates.io) dependencies # # If you believe there's an error in this file please file an # issue against the rust-lang/cargo repository. If you're @@ -12,7 +12,7 @@ [package] name = "directories" -version = "2.0.1" +version = "4.0.1" authors = ["Simon Ochsenreither "] description = "A tiny mid-level library that provides platform-specific standard locations of directories for config, cache and other data on Linux, Windows and macOS by leveraging the mechanisms defined by the XDG base/user directory specifications on Linux, the Known Folder API on Windows, and the Standard Directory guidelines on macOS." readme = "README.md" @@ -23,10 +23,7 @@ [[bench]] name = "constructors" harness = false -[dependencies.cfg-if] -version = "0.1" - [dependencies.dirs-sys] -version = "0.3.3" +version = "0.3.6" [dev-dependencies.bencher] version = "0.1.5" diff -Nru rust-directories-2.0.1/Cargo.toml.orig rust-directories-4.0.1/Cargo.toml.orig --- rust-directories-2.0.1/Cargo.toml.orig 1970-01-01 00:00:00.000000000 +0000 +++ rust-directories-4.0.1/Cargo.toml.orig 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +1,20 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies -# -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) - [package] -name = "directories" -version = "2.0.1" -authors = ["Simon Ochsenreither "] +name = "directories" +version = "4.0.1" +authors = ["Simon Ochsenreither "] description = "A tiny mid-level library that provides platform-specific standard locations of directories for config, cache and other data on Linux, Windows and macOS by leveraging the mechanisms defined by the XDG base/user directory specifications on Linux, the Known Folder API on Windows, and the Standard Directory guidelines on macOS." -readme = "README.md" -keywords = ["xdg", "basedir", "app_dirs", "path", "folder"] -license = "MIT OR Apache-2.0" -repository = "https://github.com/soc/directories-rs" +readme = "README.md" +license = "MIT OR Apache-2.0" +repository = "https://github.com/soc/directories-rs" +maintenance = { status = "actively-developed" } +keywords = ["xdg", "basedir", "app_dirs", "path", "folder"] + +[dependencies] +dirs-sys = "0.3.6" + +[dev-dependencies] +bencher = "0.1.5" [[bench]] name = "constructors" harness = false -[dependencies.cfg-if] -version = "0.1" - -[dependencies.dirs-sys] -version = "0.3.3" -[dev-dependencies.bencher] -version = "0.1.5" diff -Nru rust-directories-2.0.1/.cargo_vcs_info.json rust-directories-4.0.1/.cargo_vcs_info.json --- rust-directories-2.0.1/.cargo_vcs_info.json 1970-01-01 00:00:00.000000000 +0000 +++ rust-directories-4.0.1/.cargo_vcs_info.json 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +1,5 @@ { "git": { - "sha1": "f06a0ad1f2646d4854763dc4d969c76e22d5f785" + "sha1": "0a890f0c80acb96db736906b9309bac98fb844db" } } diff -Nru rust-directories-2.0.1/debian/cargo-checksum.json rust-directories-4.0.1/debian/cargo-checksum.json --- rust-directories-2.0.1/debian/cargo-checksum.json 2019-08-12 14:58:39.000000000 +0000 +++ rust-directories-4.0.1/debian/cargo-checksum.json 2022-07-02 20:49:51.000000000 +0000 @@ -1 +1 @@ -{"package":"551a778172a450d7fc12e629ca3b0428d00f6afa9a43da1b630d54604e97371c","files":{}} +{"package":"f51c5d4ddabd36886dd3e1438cb358cdcb0d7c499cb99cb4ac2e38e18b5cb210","files":{}} diff -Nru rust-directories-2.0.1/debian/changelog rust-directories-4.0.1/debian/changelog --- rust-directories-2.0.1/debian/changelog 2019-08-12 14:58:39.000000000 +0000 +++ rust-directories-4.0.1/debian/changelog 2022-07-02 20:49:51.000000000 +0000 @@ -1,3 +1,10 @@ +rust-directories (4.0.1-1) unstable; urgency=medium + + * Team upload. + * Package directories 4.0.1 from crates.io using debcargo 2.5.0 (Closes: 1014245) + + -- Peter Michael Green Sat, 02 Jul 2022 20:49:51 +0000 + rust-directories (2.0.1-1) unstable; urgency=medium * Package directories 2.0.1 from crates.io using debcargo 2.2.10 diff -Nru rust-directories-2.0.1/debian/compat rust-directories-4.0.1/debian/compat --- rust-directories-2.0.1/debian/compat 2019-08-12 14:58:39.000000000 +0000 +++ rust-directories-4.0.1/debian/compat 2022-07-02 20:49:51.000000000 +0000 @@ -1 +1 @@ -11 +12 diff -Nru rust-directories-2.0.1/debian/control rust-directories-4.0.1/debian/control --- rust-directories-2.0.1/debian/control 2019-08-12 14:58:39.000000000 +0000 +++ rust-directories-4.0.1/debian/control 2022-07-02 20:49:51.000000000 +0000 @@ -1,37 +1,36 @@ Source: rust-directories Section: rust Priority: optional -Build-Depends: debhelper (>= 11), - dh-cargo (>= 15), +Build-Depends: debhelper (>= 12), + dh-cargo (>= 25), cargo:native , rustc:native , libstd-rust-dev , - librust-cfg-if-0.1+default-dev , - librust-dirs-sys-0.3+default-dev (>= 0.3.3-~~) + librust-dirs-sys-0.3+default-dev (>= 0.3.6-~~) Maintainer: Debian Rust Maintainers Uploaders: Andrej Shadura -Standards-Version: 4.2.0 +Standards-Version: 4.5.1 Vcs-Git: https://salsa.debian.org/rust-team/debcargo-conf.git [src/directories] Vcs-Browser: https://salsa.debian.org/rust-team/debcargo-conf/tree/master/src/directories +Rules-Requires-Root: no -# FIXME (packages."(name)".section) debcargo auto-generated summaries are very long, consider overriding +# FIXME (packages."(name)".section) debcargo auto-generated summary for librust-directories-dev is very long, consider overriding Package: librust-directories-dev Architecture: any Multi-Arch: same Depends: ${misc:Depends}, - librust-cfg-if-0.1+default-dev, - librust-dirs-sys-0.3+default-dev (>= 0.3.4-~~) + librust-dirs-sys-0.3+default-dev (>= 0.3.6-~~) Provides: librust-directories+default-dev (= ${binary:Version}), - librust-directories-2-dev (= ${binary:Version}), - librust-directories-2+default-dev (= ${binary:Version}), - librust-directories-2.0-dev (= ${binary:Version}), - librust-directories-2.0+default-dev (= ${binary:Version}), - librust-directories-2.0.2-dev (= ${binary:Version}), - librust-directories-2.0.2+default-dev (= ${binary:Version}) + librust-directories-4-dev (= ${binary:Version}), + librust-directories-4+default-dev (= ${binary:Version}), + librust-directories-4.0-dev (= ${binary:Version}), + librust-directories-4.0+default-dev (= ${binary:Version}), + librust-directories-4.0.1-dev (= ${binary:Version}), + librust-directories-4.0.1+default-dev (= ${binary:Version}) Description: Tiny mid-level library that provides platform-specific standard locations of directories for config, cache and other data on Linux, Windows and macOS by leveraging the mechanisms defined by the XDG base/user directory specifications on Linux, the Known Folder API on Windows, and the Standard Directory guidelines on macOS - Rust source code This package contains the source for the Rust directories crate, packaged by debcargo for use with cargo and dh-cargo. diff -Nru rust-directories-2.0.1/debian/copyright rust-directories-4.0.1/debian/copyright --- rust-directories-2.0.1/debian/copyright 2019-08-12 14:58:39.000000000 +0000 +++ rust-directories-4.0.1/debian/copyright 2022-07-02 20:49:51.000000000 +0000 @@ -4,12 +4,12 @@ Source: https://github.com/soc/directories-rs Files: * -Copyright: 2017—2019 Simon Ochsenreither +Copyright: 2017—2021 Simon Ochsenreither License: MIT or Apache-2.0 Files: debian/* Copyright: - 2019 Debian Rust Maintainers + 2019-2022 Debian Rust Maintainers 2019 Andrej Shadura License: MIT or Apache-2.0 diff -Nru rust-directories-2.0.1/debian/copyright.debcargo.hint rust-directories-4.0.1/debian/copyright.debcargo.hint --- rust-directories-2.0.1/debian/copyright.debcargo.hint 2019-08-12 14:58:39.000000000 +0000 +++ rust-directories-4.0.1/debian/copyright.debcargo.hint 2022-07-02 20:49:51.000000000 +0000 @@ -21,8 +21,8 @@ Files: debian/* Copyright: - 2019 Debian Rust Maintainers - 2019 Andrej Shadura + 2019-2022 Debian Rust Maintainers + 2019-2022 Andrej Shadura License: MIT or Apache-2.0 License: Apache-2.0 diff -Nru rust-directories-2.0.1/debian/tests/control rust-directories-4.0.1/debian/tests/control --- rust-directories-2.0.1/debian/tests/control 1970-01-01 00:00:00.000000000 +0000 +++ rust-directories-4.0.1/debian/tests/control 2022-07-02 20:49:51.000000000 +0000 @@ -0,0 +1,14 @@ +Test-Command: /usr/share/cargo/bin/cargo-auto-test directories 4.0.1 --all-targets --all-features +Features: test-name=rust-directories:@ +Depends: dh-cargo (>= 18), librust-bencher-0.1+default-dev (>= 0.1.5-~~), @ +Restrictions: allow-stderr, skip-not-installable + +Test-Command: /usr/share/cargo/bin/cargo-auto-test directories 4.0.1 --all-targets +Features: test-name=librust-directories-dev:default +Depends: dh-cargo (>= 18), librust-bencher-0.1+default-dev (>= 0.1.5-~~), @ +Restrictions: allow-stderr, skip-not-installable + +Test-Command: /usr/share/cargo/bin/cargo-auto-test directories 4.0.1 --all-targets --no-default-features +Features: test-name=librust-directories-dev: +Depends: dh-cargo (>= 18), librust-bencher-0.1+default-dev (>= 0.1.5-~~), @ +Restrictions: allow-stderr, skip-not-installable diff -Nru rust-directories-2.0.1/debian/watch rust-directories-4.0.1/debian/watch --- rust-directories-2.0.1/debian/watch 2019-08-12 14:58:39.000000000 +0000 +++ rust-directories-4.0.1/debian/watch 2022-07-02 20:49:51.000000000 +0000 @@ -2,4 +2,3 @@ opts=filenamemangle=s/.*\/(.*)\/download/directories-$1\.tar\.gz/g,\ uversionmangle=s/(\d)[_\.\-\+]?((RC|rc|pre|dev|beta|alpha)\d*)$/$1~$2/ \ https://qa.debian.org/cgi-bin/fakeupstream.cgi?upstream=crates.io/directories .*/crates/directories/@ANY_VERSION@/download - diff -Nru rust-directories-2.0.1/README.md rust-directories-4.0.1/README.md --- rust-directories-2.0.1/README.md 2019-05-30 22:01:26.000000000 +0000 +++ rust-directories-4.0.1/README.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +1,7 @@ [![crates.io](https://img.shields.io/crates/v/directories.svg)](https://crates.io/crates/directories) [![API documentation](https://docs.rs/directories/badge.svg)](https://docs.rs/directories/) ![actively developed](https://img.shields.io/badge/maintenance-actively--developed-brightgreen.svg) -[![TravisCI status](https://img.shields.io/travis/soc/directories-rs/master.svg?label=Linux/macOS%20build)](https://travis-ci.org/soc/directories-rs) +[![TravisCI status](https://img.shields.io/travis/dirs-dev/directories-rs/master.svg?label=Linux/macOS%20build)](https://travis-ci.org/dirs-dev/directories-rs) [![AppVeyor status](https://img.shields.io/appveyor/ci/soc/directories-rs/master.svg?label=Windows%20build)](https://ci.appveyor.com/project/soc/directories-rs/branch/master) ![License: MIT/Apache-2.0](https://img.shields.io/badge/license-MIT%2FApache--2.0-orange.svg) @@ -37,11 +37,13 @@ Add the library as a dependency to your project by inserting ```toml -directories = "1.0" +directories = "4.0" ``` into the `[dependencies]` section of your Cargo.toml file. +If you are upgrading from version 2, please read the [section on breaking changes](#3) first. + #### Example Library run by user Alice: @@ -54,7 +56,7 @@ proj_dirs.config_dir(); // Lin: /home/alice/.config/barapp // Win: C:\Users\Alice\AppData\Roaming\Foo Corp\Bar App\config - // Mac: /Users/Alice/Library/Preferences/com.Foo-Corp.Bar-App + // Mac: /Users/Alice/Library/Application Support/com.Foo-Corp.Bar-App } if let Some(base_dirs) = BaseDirs::new() { @@ -75,15 +77,16 @@ ## Design Goals - The _directories_ library is designed to provide an accurate snapshot of the system's state at - the point of invocation of `BaseDirs::new`, `UserDirs::new` or `ProjectDirs::from`. Subsequent - changes to the state of the system are not reflected in values created prior to such a change. + the point of invocation of `BaseDirs::new`, `UserDirs::new` or `ProjectDirs::from`.
+ Subsequent changes to the state of the system are not reflected in values created prior to such a change. - This library does not create directories or check for their existence. The library only provides - information on what the path to a certain directory _should_ be. How this information is used is - a decision that developers need to make based on the requirements of each individual application. -- This library is intentionally focused on providing information on user-writable directories only. - There is no discernible benefit in returning a path that points to a user-level, writable - directory on one operating system, but a system-level, read-only directory on another, that would - outweigh the confusion and unexpected failures such an approach would cause. + information on what the path to a certain directory _should_ be.
+ How this information is used is a decision that developers need to make based on the requirements + of each individual application. +- This library is intentionally focused on providing information on user-writable directories only, + as there is no discernible benefit in returning a path that points to a user-level, writable + directory on one operating system, but a system-level, read-only directory on another.
+ The confusion and unexpected failure modes of such an approach would be immense. - `executable_dir` is specified to provide the path to a user-writable directory for binaries.
As such a directory only commonly exists on Linux, it returns `None` on macOS and Windows. - `font_dir` is specified to provide the path to a user-writable directory for fonts.
@@ -103,15 +106,17 @@ If you want to compute the location of cache, config or data directories for your own application or project, use `ProjectDirs` instead. -| Function name | Value on Linux | Value on Windows | Value on macOS | -| ---------------- | ----------------------------------------------------------------------------------------------- | --------------------------- | ----------------------------------- | -| `home_dir` | `$HOME` | `{FOLDERID_Profile}` | `$HOME` | -| `cache_dir` | `$XDG_CACHE_HOME` or `$HOME`/.cache | `{FOLDERID_LocalAppData}` | `$HOME`/Library/Caches | -| `config_dir` | `$XDG_CONFIG_HOME` or `$HOME`/.config | `{FOLDERID_RoamingAppData}` | `$HOME`/Library/Preferences | -| `data_dir` | `$XDG_DATA_HOME` or `$HOME`/.local/share | `{FOLDERID_RoamingAppData}` | `$HOME`/Library/Application Support | -| `data_local_dir` | `$XDG_DATA_HOME` or `$HOME`/.local/share | `{FOLDERID_LocalAppData}` | `$HOME`/Library/Application Support | -| `executable_dir` | `Some($XDG_BIN_HOME`/../bin`)` or `Some($XDG_DATA_HOME`/../bin`)` or `Some($HOME`/.local/bin`)` | `None` | `None` | -| `runtime_dir` | `Some($XDG_RUNTIME_DIR)` or `None` | `None` | `None` | +| Function name | Value on Linux | Value on Windows | Value on macOS | +| ---------------- | -------------------------------------------------------- | --------------------------- | ----------------------------------- | +| `home_dir` | `$HOME` | `{FOLDERID_Profile}` | `$HOME` | +| `cache_dir` | `$XDG_CACHE_HOME` or `$HOME`/.cache | `{FOLDERID_LocalAppData}` | `$HOME`/Library/Caches | +| `config_dir` | `$XDG_CONFIG_HOME` or `$HOME`/.config | `{FOLDERID_RoamingAppData}` | `$HOME`/Library/Application Support | +| `data_dir` | `$XDG_DATA_HOME` or `$HOME`/.local/share | `{FOLDERID_RoamingAppData}` | `$HOME`/Library/Application Support | +| `data_local_dir` | `$XDG_DATA_HOME` or `$HOME`/.local/share | `{FOLDERID_LocalAppData}` | `$HOME`/Library/Application Support | +| `executable_dir` | `Some($XDG_BIN_HOME)` or `Some($HOME`/.local/bin`)` | `None` | `None` | +| `preference_dir` | `$XDG_CONFIG_HOME` or `$HOME`/.config | `{FOLDERID_RoamingAppData}` | `$HOME`/Library/Preferences | +| `runtime_dir` | `Some($XDG_RUNTIME_DIR)` or `None` | `None` | `None` | +| `state_dir` | `Some($XDG_STATE_HOME)` or `Some($HOME`/.local/state`)` | `None` | `None` | ### `UserDirs` @@ -139,10 +144,12 @@ | Function name | Value on Linux | Value on Windows | Value on macOS | | ---------------- | ---------------------------------------------------------------------------------- | --------------------------------------------------- | ---------------------------------------------------- | | `cache_dir` | `$XDG_CACHE_HOME`/`` or `$HOME`/.cache/`` | `{FOLDERID_LocalAppData}`/``/cache | `$HOME`/Library/Caches/`` | -| `config_dir` | `$XDG_CONFIG_HOME`/`` or `$HOME`/.config/`` | `{FOLDERID_RoamingAppData}`/``/config | `$HOME`/Library/Preferences/`` | +| `config_dir` | `$XDG_CONFIG_HOME`/`` or `$HOME`/.config/`` | `{FOLDERID_RoamingAppData}`/``/config | `$HOME`/Library/Application Support/`` | | `data_dir` | `$XDG_DATA_HOME`/`` or `$HOME`/.local/share/`` | `{FOLDERID_RoamingAppData}`/``/data | `$HOME`/Library/Application Support/`` | | `data_local_dir` | `$XDG_DATA_HOME`/`` or `$HOME`/.local/share/`` | `{FOLDERID_LocalAppData}`/``/data | `$HOME`/Library/Application Support/`` | -| `runtime_dir` | `Some($XDG_RUNTIME_DIR`/`_project_path_)` | `None` | `None` | +| `preference_dir` | `$XDG_CONFIG_HOME`/`` or `$HOME`/.config/`` | `{FOLDERID_RoamingAppData}`/``/config | `$HOME`/Library/Preferences/`` | +| `runtime_dir` | `Some($XDG_RUNTIME_DIR`/`)` | `None` | `None` | +| `state_dir` | `Some($XDG_STATE_HOME`/`)` or `$HOME`/.local/state/`` | `None` | `None` | The specific value of `` is computed by the @@ -164,6 +171,7 @@ The `ProjectDirs::from_path` function allows the creation of `ProjectDirs` structs directly from a `PathBuf` value. This argument is used verbatim and is not adapted to operating system standards. + The use of `ProjectDirs::from_path` is strongly discouraged, as its results will not follow operating system standards on at least two of three platforms. ## Comparison @@ -210,9 +218,32 @@ ## Changelog +### 4 + +- **BREAKING CHANGE** The behavior of `executable_dir` has been adjusted to not depend on `$XDG_DATA_HOME`. + Code, which assumed that setting the `$XDG_DATA_HOME` environment variable also impacted `executable_dir` if + the `$XDG_BIN_HOME` environment variable was not set, requires adjustment. +- Add support for `XDG_STATE_HOME`. + +### 3 + +- **BREAKING CHANGE** The behavior of the `BaseDirs::config_dir` and `ProjectDirs::config_dir` + on macOS has been adjusted (thanks to [everyone involved](https://github.com/dirs-dev/directories-rs/issues/62)): + - The existing `config_dir` functions have been changed to return the `Application Support` + directory on macOS, as suggested by Apple documentation. + - The behavior of the `config_dir` functions on non-macOS platforms has not been changed. + - If you have used the `config_dir` functions to store files, it may be necessary to write code + that migrates the files to the new location on macOS.
+ (Alternative: change uses of the `config_dir` functions to uses of the `preference_dir` functions + to retain the old behavior.) +- The newly added `BaseDirs::preference_dir` and `ProjectDirs::preference_dir` functions returns + the `Preferences` directory on macOS now, which – according to Apple documentation – shall only + be used to store .plist files using Apple-proprietary APIs. + – `preference_dir` and `config_dir` behave identical on non-macOS platforms. + ### 2 -The behavior of deactivated, missing or invalid [_XDG User Dirs_](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/) +**BREAKING CHANGE** The behavior of deactivated, missing or invalid [_XDG User Dirs_](https://www.freedesktop.org/wiki/Software/xdg-user-dirs/) entries on Linux has been improved (contributed by @tmiasko, thank you!): - Version 1 returned the user's home directory (`Some($HOME)`) for such faulty entries, except for a faulty `XDG_DESKTOP_DIR` entry which returned (`Some($HOME/Desktop)`). diff -Nru rust-directories-2.0.1/src/lib.rs rust-directories-4.0.1/src/lib.rs --- rust-directories-2.0.1/src/lib.rs 2019-05-30 22:01:26.000000000 +0000 +++ rust-directories-4.0.1/src/lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -14,27 +14,33 @@ #![deny(missing_docs)] -#[macro_use] -extern crate cfg_if; - use std::path::Path; use std::path::PathBuf; -cfg_if! { - if #[cfg(target_os = "windows")] { - mod win; - use win as sys; - } else if #[cfg(target_os = "macos")] { - mod mac; - use mac as sys; - } else if #[cfg(target_os = "wasi")] { - mod wasi; - use wasi as sys; - } else { - mod lin; - use lin as sys; - } -} +#[cfg(target_os = "windows")] +mod win; +#[cfg(target_os = "windows")] +use win as sys; +#[cfg(any(target_os = "macos", target_os = "ios"))] +mod mac; +#[cfg(any(target_os = "macos", target_os = "ios"))] +use mac as sys; +#[cfg(target_arch = "wasm32")] +mod wasm; +#[cfg(target_arch = "wasm32")] +use wasm as sys; +#[cfg(not(any( + target_os = "windows", + target_os = "macos", target_os = "ios", + target_arch = "wasm32" +)))] +mod lin; +#[cfg(not(any( + target_os = "windows", + target_os = "macos", target_os = "ios", + target_arch = "wasm32" +)))] +use lin as sys; /// `BaseDirs` provides paths of user-invisible standard directories, following the conventions of the operating system the library is running on. /// @@ -50,7 +56,7 @@ /// base_dirs.config_dir(); /// // Linux: /home/alice/.config /// // Windows: C:\Users\Alice\AppData\Roaming -/// // macOS: /Users/Alice/Library/Preferences +/// // macOS: /Users/Alice/Library/Application Support /// } /// ``` #[derive(Debug, Clone)] @@ -64,7 +70,9 @@ data_dir: PathBuf, data_local_dir: PathBuf, executable_dir: Option, + preference_dir: PathBuf, runtime_dir: Option, + state_dir: Option } /// `UserDirs` provides paths of user-facing standard directories, following the conventions of the operating system the library is running on. @@ -114,7 +122,7 @@ /// proj_dirs.config_dir(); /// // Linux: /home/alice/.config/barapp /// // Windows: C:\Users\Alice\AppData\Roaming\Foo Corp\Bar App -/// // macOS: /Users/Alice/Library/Preferences/com.Foo-Corp.Bar-App +/// // macOS: /Users/Alice/Library/Application Support/com.Foo-Corp.Bar-App /// } /// ``` #[derive(Debug, Clone)] @@ -126,7 +134,9 @@ config_dir: PathBuf, data_dir: PathBuf, data_local_dir: PathBuf, - runtime_dir: Option + preference_dir: PathBuf, + runtime_dir: Option, + state_dir: Option } impl BaseDirs { @@ -180,11 +190,11 @@ } /// Returns the path to the user's config directory. /// - /// |Platform | Value | Example | - /// | ------- | ------------------------------------- | -------------------------------- | - /// | Linux | `$XDG_CONFIG_HOME` or `$HOME`/.config | /home/alice/.config | - /// | macOS | `$HOME`/Library/Preferences | /Users/Alice/Library/Preferences | - /// | Windows | `{FOLDERID_RoamingAppData}` | C:\Users\Alice\AppData\Roaming | + /// |Platform | Value | Example | + /// | ------- | ------------------------------------- | ---------------------------------------- | + /// | Linux | `$XDG_CONFIG_HOME` or `$HOME`/.config | /home/alice/.config | + /// | macOS | `$HOME`/Library/Application Support | /Users/Alice/Library/Application Support | + /// | Windows | `{FOLDERID_RoamingAppData}` | C:\Users\Alice\AppData\Roaming | pub fn config_dir(&self) -> &Path { self.config_dir.as_path() } @@ -218,6 +228,16 @@ pub fn executable_dir(&self) -> Option<&Path> { self.executable_dir.as_ref().map(|p| p.as_path()) } + /// Returns the path to the user's preference directory. + /// + /// |Platform | Value | Example | + /// | ------- | ------------------------------------- | -------------------------------- | + /// | Linux | `$XDG_CONFIG_HOME` or `$HOME`/.config | /home/alice/.config | + /// | macOS | `$HOME`/Library/Preferences | /Users/Alice/Library/Preferences | + /// | Windows | `{FOLDERID_RoamingAppData}` | C:\Users\Alice\AppData\Roaming | + pub fn preference_dir(&self) -> &Path { + self.preference_dir.as_path() + } /// Returns the path to the user's runtime directory. /// /// |Platform | Value | Example | @@ -228,6 +248,22 @@ pub fn runtime_dir(&self) -> Option<&Path> { self.runtime_dir.as_ref().map(|p| p.as_path()) } + /// Returns the path to the user's state directory. + /// + /// The state directory contains data that should be retained between sessions (unlike the runtime + /// directory), but may not be important/portable enough to be synchronized across machines (unlike + /// the config/preferences/data directories). + /// + /// The returned value depends on the operating system and is either a `Some`, containing a value from the following table, or a `None`. + /// + /// |Platform | Value | Example | + /// | ------- | ----------------------------------------- | ------------------------ | + /// | Linux | `$XDG_STATE_HOME` or `$HOME`/.local/state | /home/alice/.local/state | + /// | macOS | – | – | + /// | Windows | – | – | + pub fn state_dir(&self) -> Option<&Path> { + self.state_dir.as_ref().map(|p| p.as_path()) + } } impl UserDirs { @@ -376,10 +412,6 @@ /// - `application` – The name of the application itself.
/// Example values: `"Bar App"`, `"ExampleProgram"`, `"Unicorn-Programme"` /// - /// # Panics - /// - /// Panics if the home directory cannot be determined. See [`BaseDirs::home_dir`]. - /// /// [`BaseDirs::home_dir`]: struct.BaseDirs.html#method.home_dir pub fn from(qualifier: &str, organization: &str, application: &str) -> Option { sys::project_dirs_from(qualifier, organization, application) @@ -395,17 +427,17 @@ /// | ------- | --------------------------------------------------------------------- | --------------------------------------------------- | /// | Linux | `$XDG_CACHE_HOME`/`_project_path_` or `$HOME`/.cache/`_project_path_` | /home/alice/.cache/barapp | /// | macOS | `$HOME`/Library/Caches/`_project_path_` | /Users/Alice/Library/Caches/com.Foo-Corp.Bar-App | - /// | Windows | `{FOLDERID_LocalAppData}`\`_project_path_`\cache | C:\Users\Alice\AppData\Local\Foo Corp\Bar App\cache | + /// | Windows | `{FOLDERID_LocalAppData}`\\`_project_path_`\\cache | C:\Users\Alice\AppData\Local\Foo Corp\Bar App\cache | pub fn cache_dir(&self) -> &Path { self.cache_dir.as_path() } /// Returns the path to the project's config directory. /// - /// |Platform | Value | Example | - /// | ------- | ----------------------------------------------------------------------- | ------------------------------------------------------ | - /// | Linux | `$XDG_CONFIG_HOME`/`_project_path_` or `$HOME`/.config/`_project_path_` | /home/alice/.config/barapp | - /// | macOS | `$HOME`/Library/Preferences/`_project_path_` | /Users/Alice/Library/Preferences/com.Foo-Corp.Bar-App | - /// | Windows | `{FOLDERID_RoamingAppData}`\`_project_path_`\config | C:\Users\Alice\AppData\Roaming\Foo Corp\Bar App\config | + /// |Platform | Value | Example | + /// | ------- | ----------------------------------------------------------------------- | -------------------------------------------------------------- | + /// | Linux | `$XDG_CONFIG_HOME`/`_project_path_` or `$HOME`/.config/`_project_path_` | /home/alice/.config/barapp | + /// | macOS | `$HOME`/Library/Application Support/`_project_path_` | /Users/Alice/Library/Application Support/com.Foo-Corp.Bar-App | + /// | Windows | `{FOLDERID_RoamingAppData}`\\`_project_path_`\\config | C:\Users\Alice\AppData\Roaming\Foo Corp\Bar App\config | pub fn config_dir(&self) -> &Path { self.config_dir.as_path() } @@ -415,7 +447,7 @@ /// | ------- | -------------------------------------------------------------------------- | ------------------------------------------------------------- | /// | Linux | `$XDG_DATA_HOME`/`_project_path_` or `$HOME`/.local/share/`_project_path_` | /home/alice/.local/share/barapp | /// | macOS | `$HOME`/Library/Application Support/`_project_path_` | /Users/Alice/Library/Application Support/com.Foo-Corp.Bar-App | - /// | Windows | `{FOLDERID_RoamingAppData}`\`_project_path_`\data | C:\Users\Alice\AppData\Roaming\Foo Corp\Bar App\data | + /// | Windows | `{FOLDERID_RoamingAppData}`\\`_project_path_`\\data | C:\Users\Alice\AppData\Roaming\Foo Corp\Bar App\data | pub fn data_dir(&self) -> &Path { self.data_dir.as_path() } @@ -425,12 +457,25 @@ /// | ------- | -------------------------------------------------------------------------- | ------------------------------------------------------------- | /// | Linux | `$XDG_DATA_HOME`/`_project_path_` or `$HOME`/.local/share/`_project_path_` | /home/alice/.local/share/barapp | /// | macOS | `$HOME`/Library/Application Support/`_project_path_` | /Users/Alice/Library/Application Support/com.Foo-Corp.Bar-App | - /// | Windows | `{FOLDERID_LocalAppData}`\`_project_path_`\data | C:\Users\Alice\AppData\Local\Foo Corp\Bar App\data | + /// | Windows | `{FOLDERID_LocalAppData}`\\`_project_path_`\\data | C:\Users\Alice\AppData\Local\Foo Corp\Bar App\data | pub fn data_local_dir(&self) -> &Path { self.data_local_dir.as_path() } + /// Returns the path to the project's preference directory. + /// + /// |Platform | Value | Example | + /// | ------- | ----------------------------------------------------------------------- | ------------------------------------------------------ | + /// | Linux | `$XDG_CONFIG_HOME`/`_project_path_` or `$HOME`/.config/`_project_path_` | /home/alice/.config/barapp | + /// | macOS | `$HOME`/Library/Preferences/`_project_path_` | /Users/Alice/Library/Preferences/com.Foo-Corp.Bar-App | + /// | Windows | `{FOLDERID_RoamingAppData}`\\`_project_path_`\\config | C:\Users\Alice\AppData\Roaming\Foo Corp\Bar App\config | + pub fn preference_dir(&self) -> &Path { + self.preference_dir.as_path() + } /// Returns the path to the project's runtime directory. /// + /// The runtime directory contains transient, non-essential data (like sockets or named pipes) that + /// is expected to be cleared when the user's session ends. + /// /// |Platform | Value | Example | /// | ------- | ----------------------------------- | --------------------- | /// | Linux | `$XDG_RUNTIME_DIR`/`_project_path_` | /run/user/1001/barapp | @@ -439,6 +484,22 @@ pub fn runtime_dir(&self) -> Option<&Path> { self.runtime_dir.as_ref().map(|p| p.as_path()) } + /// Returns the path to the project's state directory. + /// + /// The state directory contains data that should be retained between sessions (unlike the runtime + /// directory), but may not be important/portable enough to be synchronized across machines (unlike + /// the config/preferences/data directories). + /// + /// The returned value depends on the operating system and is either a `Some`, containing a value from the following table, or a `None`. + /// + /// |Platform | Value | Example | + /// | ------- | --------------------------------------------------------------------------- | ------------------------------- | + /// | Linux | `$XDG_STATE_HOME`/`_project_path_` or `$HOME`/.local/state/`_project_path_` | /home/alice/.local/state/barapp | + /// | macOS | – | – | + /// | Windows | – | – | + pub fn state_dir(&self) -> Option<&Path> { + self.state_dir.as_ref().map(|p| p.as_path()) + } } #[cfg(test)] diff -Nru rust-directories-2.0.1/src/lin.rs rust-directories-4.0.1/src/lin.rs --- rust-directories-2.0.1/src/lin.rs 2019-05-30 22:01:26.000000000 +0000 +++ rust-directories-4.0.1/src/lin.rs 1970-01-01 00:00:00.000000000 +0000 @@ -13,10 +13,10 @@ let config_dir = env::var_os("XDG_CONFIG_HOME").and_then(dirs_sys::is_absolute_path).unwrap_or_else(|| home_dir.join(".config")); let data_dir = env::var_os("XDG_DATA_HOME") .and_then(dirs_sys::is_absolute_path).unwrap_or_else(|| home_dir.join(".local/share")); let data_local_dir = data_dir.clone(); + let preference_dir = config_dir.clone(); let runtime_dir = env::var_os("XDG_RUNTIME_DIR").and_then(dirs_sys::is_absolute_path); - let executable_dir = - env::var_os("XDG_BIN_HOME").and_then(dirs_sys::is_absolute_path).unwrap_or_else(|| { - let mut new_dir = data_dir.clone(); new_dir.pop(); new_dir.push("bin"); new_dir }); + let state_dir = env::var_os("XDG_STATE_HOME") .and_then(dirs_sys::is_absolute_path).unwrap_or_else(|| home_dir.join(".local/state")); + let executable_dir = env::var_os("XDG_BIN_HOME") .and_then(dirs_sys::is_absolute_path).unwrap_or_else(|| home_dir.join(".local/bin")); let base_dirs = BaseDirs { home_dir: home_dir, @@ -25,7 +25,9 @@ data_dir: data_dir, data_local_dir: data_local_dir, executable_dir: Some(executable_dir), - runtime_dir: runtime_dir + preference_dir: preference_dir, + runtime_dir: runtime_dir, + state_dir: Some(state_dir) }; Some(base_dirs) } else { @@ -63,7 +65,9 @@ let config_dir = env::var_os("XDG_CONFIG_HOME").and_then(dirs_sys::is_absolute_path).unwrap_or_else(|| home_dir.join(".config")).join(&project_path); let data_dir = env::var_os("XDG_DATA_HOME") .and_then(dirs_sys::is_absolute_path).unwrap_or_else(|| home_dir.join(".local/share")).join(&project_path); let data_local_dir = data_dir.clone(); + let preference_dir = config_dir.clone(); let runtime_dir = env::var_os("XDG_RUNTIME_DIR").and_then(dirs_sys::is_absolute_path).map(|o| o.join(&project_path)); + let state_dir = env::var_os("XDG_STATE_HOME") .and_then(dirs_sys::is_absolute_path).unwrap_or_else(|| home_dir.join(".local/state")).join(&project_path); let project_dirs = ProjectDirs { project_path: project_path, @@ -71,7 +75,9 @@ config_dir: config_dir, data_dir: data_dir, data_local_dir: data_local_dir, - runtime_dir: runtime_dir + preference_dir: preference_dir, + runtime_dir: runtime_dir, + state_dir: Some(state_dir) }; Some(project_dirs) } else { diff -Nru rust-directories-2.0.1/src/mac.rs rust-directories-4.0.1/src/mac.rs --- rust-directories-2.0.1/src/mac.rs 2019-05-30 22:01:26.000000000 +0000 +++ rust-directories-4.0.1/src/mac.rs 1970-01-01 00:00:00.000000000 +0000 @@ -9,9 +9,10 @@ pub fn base_dirs() -> Option { if let Some(home_dir) = dirs_sys::home_dir() { let cache_dir = home_dir.join("Library/Caches"); - let config_dir = home_dir.join("Library/Preferences"); + let config_dir = home_dir.join("Library/Application Support"); let data_dir = home_dir.join("Library/Application Support"); let data_local_dir = data_dir.clone(); + let preference_dir = home_dir.join("Library/Preferences"); let base_dirs = BaseDirs { home_dir: home_dir, @@ -20,7 +21,9 @@ data_dir: data_dir, data_local_dir: data_local_dir, executable_dir: None, - runtime_dir: None + preference_dir: preference_dir, + runtime_dir: None, + state_dir: None }; Some(base_dirs) } else { @@ -60,9 +63,10 @@ pub fn project_dirs_from_path(project_path: PathBuf) -> Option { if let Some(home_dir) = dirs_sys::home_dir() { let cache_dir = home_dir.join("Library/Caches").join(&project_path); - let config_dir = home_dir.join("Library/Preferences").join(&project_path); + let config_dir = home_dir.join("Library/Application Support").join(&project_path); let data_dir = home_dir.join("Library/Application Support").join(&project_path); let data_local_dir = data_dir.clone(); + let preference_dir = home_dir.join("Library/Preferences").join(&project_path); let project_dirs = ProjectDirs { project_path: project_path, @@ -70,7 +74,9 @@ config_dir: config_dir, data_dir: data_dir, data_local_dir: data_local_dir, + preference_dir: preference_dir, runtime_dir: None, + state_dir: None }; Some(project_dirs) } else { diff -Nru rust-directories-2.0.1/src/wasi.rs rust-directories-4.0.1/src/wasi.rs --- rust-directories-2.0.1/src/wasi.rs 2019-05-30 22:01:26.000000000 +0000 +++ rust-directories-4.0.1/src/wasi.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// Stub definitions to make things *compile*. - -use std::path::PathBuf; - -use BaseDirs; -use UserDirs; -use ProjectDirs; - -pub fn base_dirs() -> Option { None } -pub fn user_dirs() -> Option { None } -pub fn project_dirs_from_path(project_path: PathBuf) -> Option { None } -pub fn project_dirs_from(qualifier: &str, organization: &str, application: &str) -> Option { None } diff -Nru rust-directories-2.0.1/src/wasm.rs rust-directories-4.0.1/src/wasm.rs --- rust-directories-2.0.1/src/wasm.rs 1970-01-01 00:00:00.000000000 +0000 +++ rust-directories-4.0.1/src/wasm.rs 1970-01-01 00:00:00.000000000 +0000 @@ -0,0 +1,12 @@ +// Stub definitions to make things *compile*. + +use std::path::PathBuf; + +use BaseDirs; +use UserDirs; +use ProjectDirs; + +pub fn base_dirs() -> Option { None } +pub fn user_dirs() -> Option { None } +pub fn project_dirs_from_path(project_path: PathBuf) -> Option { None } +pub fn project_dirs_from(qualifier: &str, organization: &str, application: &str) -> Option { None } diff -Nru rust-directories-2.0.1/src/win.rs rust-directories-4.0.1/src/win.rs --- rust-directories-2.0.1/src/win.rs 2019-05-30 22:01:26.000000000 +0000 +++ rust-directories-4.0.1/src/win.rs 1970-01-01 00:00:00.000000000 +0000 @@ -12,8 +12,9 @@ let data_dir = dirs_sys::known_folder_roaming_app_data(); let data_local_dir = dirs_sys::known_folder_local_app_data(); if let (Some(home_dir), Some(data_dir), Some(data_local_dir)) = (home_dir, data_dir, data_local_dir) { - let cache_dir = data_local_dir.clone(); - let config_dir = data_dir.clone(); + let cache_dir = data_local_dir.clone(); + let config_dir = data_dir.clone(); + let preference_dir = data_dir.clone(); let base_dirs = BaseDirs { home_dir: home_dir, @@ -22,7 +23,9 @@ data_dir: data_dir, data_local_dir: data_local_dir, executable_dir: None, - runtime_dir: None + preference_dir: preference_dir, + runtime_dir: None, + state_dir: None }; Some(base_dirs) } else { @@ -69,6 +72,7 @@ let data_local_dir = app_data_local.join("data"); let config_dir = app_data_roaming.join("config"); let data_dir = app_data_roaming.join("data"); + let preference_dir = config_dir.clone(); let project_dirs = ProjectDirs { project_path: project_path, @@ -76,7 +80,9 @@ config_dir: config_dir, data_dir: data_dir, data_local_dir: data_local_dir, - runtime_dir: None + preference_dir: preference_dir, + runtime_dir: None, + state_dir: None }; Some(project_dirs) } else {