Bug 1772967 - Update dirs crate to 4.0. r=webdriver-reviewers,gfx-reviewers,jrmuizel,whimboo

Differential Revision: https://phabricator.services.mozilla.com/D148466
This commit is contained in:
Mike Hommey 2022-06-07 09:29:07 +00:00
Родитель f2afd39ca6
Коммит 9e959e791a
11 изменённых файлов: 167 добавлений и 86 удалений

5
Cargo.lock сгенерированный
Просмотреть файл

@ -1323,11 +1323,10 @@ dependencies = [
[[package]]
name = "dirs"
version = "2.0.2"
version = "4.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3"
checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059"
dependencies = [
"cfg-if 0.1.999",
"dirs-sys",
]

Просмотреть файл

@ -5,7 +5,7 @@ authors = ["The Mozilla Project Developers"]
license = "MPL-2.0"
[dependencies]
dirs = "2"
dirs = "4"
rayon = "1"
num_cpus = "1.7.0"
tracy-rs = "0.1"

Просмотреть файл

@ -16,7 +16,7 @@ plist = "1.0"
winreg = "0.5"
[target.'cfg(target_os = "macos")'.dependencies]
dirs = "2"
dirs = "4"
[[bin]]
name = "firefox-default-path"

2
third_party/rust/dirs/.cargo-checksum.json поставляемый
Просмотреть файл

@ -1 +1 @@
{"files":{"Cargo.toml":"08b84e4efffc2a3a8a1b31e653b916ff7b1815b4947d31332f5ad157d90e1cac","LICENSE-APACHE":"d3174ad63e721d4c9dccb8ad4320848992d314369bc46319720b5802c9153fe9","LICENSE-MIT":"6a2e0ade09a7d5f816f11566fee2b151b32235a7fad52b41d49cce96f833c1a9","README.md":"627b1ba066f1a73e44c07030ee11a456bf261c2a9a8353546e494b7733d709c1","src/lib.rs":"955d77d3850d64237a87bac1a277d46cf9fdc7d5bb2d523bf78c866b7d52f7e8","src/lin.rs":"1bde7fa7e50bc997f814d6961a296d18c4a07ef6a88e89c7bd6dd4b46f99c81d","src/mac.rs":"804dfe77b2642529bffd6e0e95b80842fa7893be07c4450c2a5e8354b1c2b6a6","src/wasm.rs":"5cc16195a6f6c475cf849af2aff765085f1f70a9ba548d38d2cbf3fed4334007","src/win.rs":"b08365e0d8777d511d5bf661ee485821ae06dade94cdaa33610a736c4e8ebb65"},"package":"13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3"}
{"files":{"Cargo.toml":"5bb02a35a3ac857c60ab16972decfea610ec3bed296a41d0235dc663a64495f6","LICENSE-APACHE":"d3174ad63e721d4c9dccb8ad4320848992d314369bc46319720b5802c9153fe9","LICENSE-MIT":"6a2e0ade09a7d5f816f11566fee2b151b32235a7fad52b41d49cce96f833c1a9","README.md":"84fdbe7a22dd22574249330ce2146d4237391989e66377f087f66eca6313c032","src/lib.rs":"d0c92741b50d0b793591e9731a71053b88a8a6e8d0e808f2d3afb127eab04b6f","src/lin.rs":"4b556c3f8a02571cd62756ff542172e5c438395c600582abb76be049c3d570c8","src/mac.rs":"4ee036a83508eae7c51ae9ccdb8165603df96a580501c11c9c2d98cd672e7940","src/wasm.rs":"6b7edb4a708fef10d95ac32aa4f7a81d465794edeb805dc7c2168e351daaca2c","src/win.rs":"8296c5f68e85ba456b48a5153cffded163d12e431a0929daa873ae09e5ce3d10"},"package":"ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059"}

16
third_party/rust/dirs/Cargo.toml поставляемый
Просмотреть файл

@ -3,24 +3,20 @@
# 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
# editing this file be aware that the upstream Cargo.toml
# will likely look very different (and much more reasonable)
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
name = "dirs"
version = "2.0.2"
version = "4.0.0"
authors = ["Simon Ochsenreither <simon@ochsenreither.de>"]
description = "A tiny low-level library that provides platform-specific standard locations of directories for config, cache and other data on Linux, Windows, macOS and Redox 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/dirs-rs"
[dependencies.cfg-if]
version = "0.1"
[dependencies.dirs-sys]
version = "0.3.4"
version = "0.3.6"

106
third_party/rust/dirs/README.md поставляемый
Просмотреть файл

@ -1,7 +1,7 @@
[![crates.io](https://img.shields.io/crates/v/dirs.svg)](https://crates.io/crates/dirs)
[![API documentation](https://docs.rs/dirs/badge.svg)](https://docs.rs/dirs/)
![actively developed](https://img.shields.io/badge/maintenance-actively--developed-brightgreen.svg)
[![TravisCI status](https://img.shields.io/travis/soc/dirs-rs/master.svg?label=Linux/macOS%20build)](https://travis-ci.org/soc/dirs-rs)
[![TravisCI status](https://img.shields.io/travis/dirs-dev/dirs-rs/master.svg?label=Linux/macOS%20build)](https://travis-ci.org/dirs-dev/dirs-rs)
[![AppVeyor status](https://img.shields.io/appveyor/ci/soc/dirs-rs/master.svg?label=Windows%20build)](https://ci.appveyor.com/project/soc/dirs-rs/branch/master)
![License: MIT/Apache-2.0](https://img.shields.io/badge/license-MIT%2FApache--2.0-orange.svg)
@ -26,10 +26,11 @@ The library provides the location of these directories by leveraging the mechani
This library is written in Rust, and supports Linux, Redox, macOS and Windows.
Other platforms are also supported; they use the Linux conventions.
The minimal required version of Rust is 1.13.
The minimal required version of Rust is 1.13 except for Redox, where the minimum Rust version
depends on the [`redox_users`](https://crates.io/crates/redox_users) crate.
It's mid-level sister library, _directories_, is available for Rust ([directories-rs](https://github.com/soc/directories-rs))
and on the JVM ([directories-jvm](https://github.com/soc/directories-jvm)).
It's mid-level sister library, _directories_, is available for Rust ([directories-rs](https://github.com/dirs-dev/directories-rs))
and on the JVM ([directories-jvm](https://github.com/dirs-dev/directories-jvm)).
## Usage
@ -38,11 +39,13 @@ and on the JVM ([directories-jvm](https://github.com/soc/directories-jvm)).
Add the library as a dependency to your project by inserting
```toml
dirs = "2.0"
dirs = "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:
@ -63,7 +66,7 @@ dirs::audio_dir();
dirs::config_dir();
// Lin: Some(/home/alice/.config)
// Win: Some(C:\Users\Alice\AppData\Roaming)
// Mac: Some(/Users/Alice/Library/Preferences)
// Mac: Some(/Users/Alice/Library/Application Support)
dirs::executable_dir();
// Lin: Some(/home/alice/.local/bin)
@ -74,16 +77,18 @@ dirs::executable_dir();
## Design Goals
- The _dirs_ library is a low-level crate designed to provide the paths to standard directories
as defined by operating systems rules or conventions. If your requirements are more complex,
e. g. computing cache, config, etc. paths for specific applications or projects, consider using
[directories](https://github.com/soc/directories-rs) instead.
as defined by operating systems rules or conventions.<br/>
If your requirements are more complex, e. g. computing cache, config, etc. paths for specific
applications or projects, consider using [directories](https://github.com/dirs-dev/directories-rs)
instead.
- 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.<br/>
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.<br/>
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.<br/>
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.<br/>
@ -97,26 +102,28 @@ dirs::executable_dir();
## Features
**If you want to compute the location of cache, config or data directories for your own application or project,
use `ProjectDirs` of the [directories](https://github.com/soc/directories-rs) project instead.**
use `ProjectDirs` of the [directories](https://github.com/dirs-dev/directories-rs) project instead.**
| Function name | Value on Linux/Redox | Value on Windows | Value on macOS |
| ---------------- | ------------------------------------------------------------------------------------------------ | --------------------------------- | ------------------------------------------- |
| `home_dir` | `Some($HOME)` | `Some({FOLDERID_Profile})` | `Some($HOME)` |
| `cache_dir` | `Some($XDG_CACHE_HOME)` or `Some($HOME`/.cache`)` | `Some({FOLDERID_LocalAppData})` | `Some($HOME`/Library/Caches`)` |
| `config_dir` | `Some($XDG_CONFIG_HOME)` or `Some($HOME`/.config`)` | `Some({FOLDERID_RoamingAppData})` | `Some($HOME`/Library/Preferences`)` |
| `data_dir` | `Some($XDG_DATA_HOME)` or `Some($HOME`/.local/share`)` | `Some({FOLDERID_RoamingAppData})` | `Some($HOME`/Library/Application Support`)` |
| `data_local_dir` | `Some($XDG_DATA_HOME)` or `Some($HOME`/.local/share`)` | `Some({FOLDERID_LocalAppData})` | `Some($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` |
| `audio_dir` | `Some(XDG_MUSIC_DIR)` or `None` | `Some({FOLDERID_Music})` | `Some($HOME`/Music/`)` |
| `desktop_dir` | `Some(XDG_DESKTOP_DIR)` or `None` | `Some({FOLDERID_Desktop})` | `Some($HOME`/Desktop/`)` |
| `document_dir` | `Some(XDG_DOCUMENTS_DIR)` or `None` | `Some({FOLDERID_Documents})` | `Some($HOME`/Documents/`)` |
| `download_dir` | `Some(XDG_DOWNLOAD_DIR)` or `None` | `Some({FOLDERID_Downloads})` | `Some($HOME`/Downloads/`)` |
| `font_dir` | `Some($XDG_DATA_HOME`/fonts/`)` or `Some($HOME`/.local/share/fonts/`)` | `None` | `Some($HOME`/Library/Fonts/`)` |
| `picture_dir` | `Some(XDG_PICTURES_DIR)` or `None` | `Some({FOLDERID_Pictures})` | `Some($HOME`/Pictures/`)` |
| `public_dir` | `Some(XDG_PUBLICSHARE_DIR)` or `None` | `Some({FOLDERID_Public})` | `Some($HOME`/Public/`)` |
| `template_dir` | `Some(XDG_TEMPLATES_DIR)` or `None` | `Some({FOLDERID_Templates})` | `None` |
| `video_dir` | `Some(XDG_VIDEOS_DIR)` or `None` | `Some({FOLDERID_Videos})` | `Some($HOME`/Movies/`)` |
| Function name | Value on Linux/Redox | Value on Windows | Value on macOS |
| ---------------- | ---------------------------------------------------------------------- | --------------------------------- | ------------------------------------------- |
| `home_dir` | `Some($HOME)` | `Some({FOLDERID_Profile})` | `Some($HOME)` |
| `cache_dir` | `Some($XDG_CACHE_HOME)` or `Some($HOME`/.cache`)` | `Some({FOLDERID_LocalAppData})` | `Some($HOME`/Library/Caches`)` |
| `config_dir` | `Some($XDG_CONFIG_HOME)` or `Some($HOME`/.config`)` | `Some({FOLDERID_RoamingAppData})` | `Some($HOME`/Library/Application Support`)` |
| `data_dir` | `Some($XDG_DATA_HOME)` or `Some($HOME`/.local/share`)` | `Some({FOLDERID_RoamingAppData})` | `Some($HOME`/Library/Application Support`)` |
| `data_local_dir` | `Some($XDG_DATA_HOME)` or `Some($HOME`/.local/share`)` | `Some({FOLDERID_LocalAppData})` | `Some($HOME`/Library/Application Support`)` |
| `executable_dir` | `Some($XDG_BIN_HOME)` or `Some($HOME`/.local/bin`)` | `None` | `None` |
| `preference_dir` | `Some($XDG_CONFIG_HOME)` or `Some($HOME`/.config`)` | `Some({FOLDERID_RoamingAppData})` | `Some($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` |
| `audio_dir` | `Some(XDG_MUSIC_DIR)` or `None` | `Some({FOLDERID_Music})` | `Some($HOME`/Music/`)` |
| `desktop_dir` | `Some(XDG_DESKTOP_DIR)` or `None` | `Some({FOLDERID_Desktop})` | `Some($HOME`/Desktop/`)` |
| `document_dir` | `Some(XDG_DOCUMENTS_DIR)` or `None` | `Some({FOLDERID_Documents})` | `Some($HOME`/Documents/`)` |
| `download_dir` | `Some(XDG_DOWNLOAD_DIR)` or `None` | `Some({FOLDERID_Downloads})` | `Some($HOME`/Downloads/`)` |
| `font_dir` | `Some($XDG_DATA_HOME`/fonts/`)` or `Some($HOME`/.local/share/fonts/`)` | `None` | `Some($HOME`/Library/Fonts/`)` |
| `picture_dir` | `Some(XDG_PICTURES_DIR)` or `None` | `Some({FOLDERID_Pictures})` | `Some($HOME`/Pictures/`)` |
| `public_dir` | `Some(XDG_PUBLICSHARE_DIR)` or `None` | `Some({FOLDERID_Public})` | `Some($HOME`/Public/`)` |
| `template_dir` | `Some(XDG_TEMPLATES_DIR)` or `None` | `Some({FOLDERID_Templates})` | `None` |
| `video_dir` | `Some(XDG_VIDEOS_DIR)` or `None` | `Some({FOLDERID_Videos})` | `Some($HOME`/Movies/`)` |
## Comparison
@ -141,9 +148,9 @@ Please take this table with a grain of salt: a different crate might very well b
- Lin: Linux support
- Mac: macOS support
- Win: Windows support
- Base: Supports [generic base directories](https://github.com/soc/directories-rs#basedirs)
- User: Supports [user directories](https://github.com/soc/directories-rs#userdirs)
- Proj: Supports [project-specific base directories](https://github.com/soc/directories-rs#projectdirs)
- Base: Supports [generic base directories](https://github.com/dirs-dev/directories-rs#basedirs)
- User: Supports [user directories](https://github.com/dirs-dev/directories-rs#userdirs)
- Proj: Supports [project-specific base directories](https://github.com/dirs-dev/directories-rs#projectdirs)
- Conv: Follows naming conventions of the operating system it runs on
## Build
@ -162,9 +169,32 @@ cargo build --target=x86_64-unknown-redox
## 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 `config_dir` on macOS has been adjusted
(thanks to [everyone involved](https://github.com/dirs-dev/directories-rs/issues/62)):
- The existing `config_dir` function has been changed to return the `Application Support`
directory on macOS, as suggested by Apple documentation.
- The behavior of the `config_dir` function on non-macOS platforms has not been changed.
- If you have used the `config_dir` function to store files, it may be necessary to write code
that migrates the files to the new location on macOS.<br/>
(Alternative: change uses of the `config_dir` function to uses of the `preference_dir` function
to retain the old behavior.)
- The newly added `preference_dir` function 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)`).

94
third_party/rust/dirs/src/lib.rs поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
//! The _dirs_ crate is
//!
//! - a tiny library with a minimal API (16 functions)
//! - a tiny library with a minimal API (18 public functions)
//! - that provides the platform-specific, user-accessible locations
//! - for finding and storing configuration, cache and other data
//! - on Linux, Redox, Windows (≥ Vista) and macOS.
@ -13,26 +13,35 @@
#![deny(missing_docs)]
#[macro_use]
extern crate cfg_if;
use std::path::PathBuf;
cfg_if! {
if #[cfg(target_os = "windows")] {
mod win;
use win as sys;
} else if #[cfg(any(target_os = "macos", target_os = "ios"))] {
mod mac;
use mac as sys;
} else if #[cfg(target_arch = "wasm32")] {
mod wasm;
use wasm 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;
/// Returns the path to the user's home directory.
///
@ -81,11 +90,11 @@ pub fn cache_dir() -> Option<PathBuf> {
///
/// 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_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() -> Option<PathBuf> {
sys::config_dir()
}
@ -125,8 +134,23 @@ pub fn data_local_dir() -> Option<PathBuf> {
pub fn executable_dir() -> Option<PathBuf> {
sys::executable_dir()
}
/// Returns the path to the user's preference directory.
///
/// 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_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() -> Option<PathBuf> {
sys::preference_dir()
}
/// Returns the path to the user'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.
///
/// 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 |
@ -137,6 +161,22 @@ pub fn executable_dir() -> Option<PathBuf> {
pub fn runtime_dir() -> Option<PathBuf> {
sys::runtime_dir()
}
/// 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() -> Option<PathBuf> {
sys::state_dir()
}
/// Returns the path to the user's audio directory.
///
@ -253,14 +293,18 @@ mod tests {
#[test]
fn test_dirs() {
println!("home_dir: {:?}", ::home_dir());
println!();
println!("cache_dir: {:?}", ::cache_dir());
println!("config_dir: {:?}", ::config_dir());
println!("data_dir: {:?}", ::data_dir());
println!("data_local_dir: {:?}", ::data_local_dir());
println!("executable_dir: {:?}", ::executable_dir());
println!("preference_dir: {:?}", ::preference_dir());
println!("runtime_dir: {:?}", ::runtime_dir());
println!("state_dir: {:?}", ::state_dir());
println!();
println!("audio_dir: {:?}", ::audio_dir());
println!("home_dir: {:?}", ::desktop_dir());
println!("desktop_dir: {:?}", ::desktop_dir());
println!("cache_dir: {:?}", ::document_dir());
println!("config_dir: {:?}", ::download_dir());
println!("font_dir: {:?}", ::font_dir());

12
third_party/rust/dirs/src/lin.rs поставляемый
Просмотреть файл

@ -4,16 +4,16 @@ use std::env;
use std::path::PathBuf;
pub fn home_dir() -> Option<PathBuf> { dirs_sys::home_dir() }
pub fn cache_dir() -> Option<PathBuf> { env::var_os("XDG_CACHE_HOME") .and_then(dirs_sys::is_absolute_path).or_else(|| home_dir().map(|h| h.join(".cache"))) }
pub fn config_dir() -> Option<PathBuf> { env::var_os("XDG_CONFIG_HOME").and_then(dirs_sys::is_absolute_path).or_else(|| home_dir().map(|h| h.join(".config"))) }
pub fn data_dir() -> Option<PathBuf> { env::var_os("XDG_DATA_HOME") .and_then(dirs_sys::is_absolute_path).or_else(|| home_dir().map(|h| h.join(".local/share"))) }
pub fn data_local_dir() -> Option<PathBuf> { data_dir().clone() }
pub fn data_local_dir() -> Option<PathBuf> { data_dir() }
pub fn preference_dir() -> Option<PathBuf> { config_dir() }
pub fn runtime_dir() -> Option<PathBuf> { env::var_os("XDG_RUNTIME_DIR").and_then(dirs_sys::is_absolute_path) }
pub fn executable_dir() -> Option<PathBuf> {
env::var_os("XDG_BIN_HOME").and_then(dirs_sys::is_absolute_path).or_else(|| {
data_dir().map(|mut e| { e.pop(); e.push("bin"); e })
})
}
pub fn state_dir() -> Option<PathBuf> { env::var_os("XDG_STATE_HOME") .and_then(dirs_sys::is_absolute_path).or_else(|| home_dir().map(|h| h.join(".local/state"))) }
pub fn executable_dir() -> Option<PathBuf> { env::var_os("XDG_BIN_HOME") .and_then(dirs_sys::is_absolute_path).or_else(|| home_dir().map(|h| h.join(".local/bin"))) }
pub fn audio_dir() -> Option<PathBuf> { dirs_sys::user_dir("MUSIC") }
pub fn desktop_dir() -> Option<PathBuf> { dirs_sys::user_dir("DESKTOP") }
pub fn document_dir() -> Option<PathBuf> { dirs_sys::user_dir("DOCUMENTS") }

6
third_party/rust/dirs/src/mac.rs поставляемый
Просмотреть файл

@ -3,12 +3,16 @@ extern crate dirs_sys;
use std::path::PathBuf;
pub fn home_dir() -> Option<PathBuf> { dirs_sys::home_dir() }
pub fn cache_dir() -> Option<PathBuf> { home_dir().map(|h| h.join("Library/Caches")) }
pub fn config_dir() -> Option<PathBuf> { home_dir().map(|h| h.join("Library/Preferences")) }
pub fn config_dir() -> Option<PathBuf> { home_dir().map(|h| h.join("Library/Application Support")) }
pub fn data_dir() -> Option<PathBuf> { home_dir().map(|h| h.join("Library/Application Support")) }
pub fn data_local_dir() -> Option<PathBuf> { data_dir() }
pub fn preference_dir() -> Option<PathBuf> { home_dir().map(|h| h.join("Library/Preferences")) }
pub fn executable_dir() -> Option<PathBuf> { None }
pub fn runtime_dir() -> Option<PathBuf> { None }
pub fn state_dir() -> Option<PathBuf> { None }
pub fn audio_dir() -> Option<PathBuf> { home_dir().map(|h| h.join("Music")) }
pub fn desktop_dir() -> Option<PathBuf> { home_dir().map(|h| h.join("Desktop")) }
pub fn document_dir() -> Option<PathBuf> { home_dir().map(|h| h.join("Documents")) }

4
third_party/rust/dirs/src/wasm.rs поставляемый
Просмотреть файл

@ -3,12 +3,16 @@
use std::path::PathBuf;
pub fn home_dir() -> Option<PathBuf> { None }
pub fn cache_dir() -> Option<PathBuf> { None }
pub fn config_dir() -> Option<PathBuf> { None }
pub fn data_dir() -> Option<PathBuf> { None }
pub fn data_local_dir() -> Option<PathBuf> { None }
pub fn preference_dir() -> Option<PathBuf> { None }
pub fn runtime_dir() -> Option<PathBuf> { None }
pub fn executable_dir() -> Option<PathBuf> { None }
pub fn state_dir() -> Option<PathBuf> { None }
pub fn audio_dir() -> Option<PathBuf> { None }
pub fn desktop_dir() -> Option<PathBuf> { None }
pub fn document_dir() -> Option<PathBuf> { None }

4
third_party/rust/dirs/src/win.rs поставляемый
Просмотреть файл

@ -3,12 +3,16 @@ extern crate dirs_sys;
use std::path::PathBuf;
pub fn home_dir() -> Option<PathBuf> { dirs_sys::known_folder_profile() }
pub fn data_dir() -> Option<PathBuf> { dirs_sys::known_folder_roaming_app_data() }
pub fn data_local_dir() -> Option<PathBuf> { dirs_sys::known_folder_local_app_data() }
pub fn cache_dir() -> Option<PathBuf> { data_local_dir() }
pub fn config_dir() -> Option<PathBuf> { data_dir() }
pub fn executable_dir() -> Option<PathBuf> { None }
pub fn preference_dir() -> Option<PathBuf> { data_dir() }
pub fn runtime_dir() -> Option<PathBuf> { None }
pub fn state_dir() -> Option<PathBuf> { None }
pub fn audio_dir() -> Option<PathBuf> { dirs_sys::known_folder_music() }
pub fn desktop_dir() -> Option<PathBuf> { dirs_sys::known_folder_desktop() }
pub fn document_dir() -> Option<PathBuf> { dirs_sys::known_folder_documents() }