mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Avoid use of deprecated (and buggy) std::env::home_dir
This commit is contained in:
parent
88664912ed
commit
e397ca06d8
4 changed files with 23 additions and 29 deletions
18
Cargo.lock
generated
18
Cargo.lock
generated
|
@ -708,6 +708,15 @@ dependencies = [
|
|||
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dlib"
|
||||
version = "0.4.1"
|
||||
|
@ -2860,6 +2869,7 @@ name = "servo_config"
|
|||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"android_injected_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dirs 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"embedder_traits 0.0.1",
|
||||
"env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2872,7 +2882,6 @@ dependencies = [
|
|||
"servo_geometry 0.0.1",
|
||||
"servo_url 0.0.1",
|
||||
"url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"xdg 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3735,11 +3744,6 @@ dependencies = [
|
|||
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "xdg"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "xi-unicode"
|
||||
version = "0.1.0"
|
||||
|
@ -3826,6 +3830,7 @@ dependencies = [
|
|||
"checksum dbus 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "acd824d45fad5ff0e178fcb3c040f13780e73f63a0a6d5cde59e7894f251ab0e"
|
||||
"checksum deflate 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ebb02aaf4b775afc96684b8402510a338086974e38570a1f65bea8c202eb77a7"
|
||||
"checksum device 0.0.1 (git+https://github.com/servo/devices)" = "<none>"
|
||||
"checksum dirs 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "37a76dd8b997af7107d0bb69d43903cf37153a18266f8b3fdb9911f28efb5444"
|
||||
"checksum dlib 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "77e51249a9d823a4cb79e3eca6dcd756153e8ed0157b6c04775d04bf1b13b76a"
|
||||
"checksum downcast-rs 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "18df8ce4470c189d18aa926022da57544f31e154631eb4cfe796aea97051fe6c"
|
||||
"checksum dtoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "80c8b71fd71146990a9742fc06dcbbde19161a267e0ad4e572c35162f4578c90"
|
||||
|
@ -4071,7 +4076,6 @@ dependencies = [
|
|||
"checksum x11-clipboard 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2e7374c7699210cca7084ca61d57e09640fc744d1391808cb9ae2fe4ca9bd1df"
|
||||
"checksum x11-dl 2.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "931d8584b49771143af0c422f372d8aef4280afd5920dad39b0a95a8e51df1e9"
|
||||
"checksum xcb 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5e917a3f24142e9ff8be2414e36c649d47d6cc2ba81f16201cdef96e533e02de"
|
||||
"checksum xdg 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a66b7c2281ebde13cf4391d70d4c7e5946c3c25e72a7b859ca8f677dcd0b0c61"
|
||||
"checksum xi-unicode 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "12ea8eda4b1eb72f02d148402e23832d56a33f55d8c1b2d5bcdde91d79d47cb1"
|
||||
"checksum xml-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c1cb601d29fe2c2ac60a2b2e5e293994d87a1f6fa9687a31a15270f909be9c2"
|
||||
"checksum xml5ever 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ead952cf8bab253fb5cb56e1fff780747bbf7a7258fb0451afe645a166050b1f"
|
||||
|
|
|
@ -28,8 +28,8 @@ url = "1.2"
|
|||
env_logger = "0.5"
|
||||
embedder_traits = { path = "../embedder_traits", features = ["tests"] }
|
||||
|
||||
[target.'cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))'.dependencies]
|
||||
xdg = "2.0"
|
||||
[target.'cfg(not(target_os = "android"))'.dependencies]
|
||||
dirs = "1.0"
|
||||
|
||||
[target.'cfg(target_os = "android")'.dependencies]
|
||||
android_injected_glue = "0.2"
|
||||
|
|
|
@ -8,18 +8,16 @@
|
|||
|
||||
#[cfg(target_os = "android")]
|
||||
use android_injected_glue;
|
||||
#[cfg(any(target_os = "macos", target_os = "windows"))]
|
||||
use std::env;
|
||||
#[cfg(target_os = "android")]
|
||||
use std::ffi::CStr;
|
||||
use std::path::PathBuf;
|
||||
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))]
|
||||
use xdg;
|
||||
|
||||
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))]
|
||||
pub fn default_config_dir() -> PathBuf {
|
||||
let xdg_dirs = xdg::BaseDirectories::with_profile("servo", "default").unwrap();
|
||||
xdg_dirs.get_config_home()
|
||||
let mut config_dir = ::dirs::config_dir().unwrap();
|
||||
config_dir.push("servo");
|
||||
config_dir.push("default");
|
||||
config_dir
|
||||
}
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
|
@ -33,24 +31,16 @@ pub fn default_config_dir() -> PathBuf {
|
|||
|
||||
#[cfg(target_os = "macos")]
|
||||
pub fn default_config_dir() -> PathBuf {
|
||||
let mut config_dir = env::home_dir().unwrap();
|
||||
config_dir.push("Library");
|
||||
config_dir.push("Application Support");
|
||||
// FIXME: use `config_dir()` ($HOME/Library/Preferences)
|
||||
// instead of `data_dir()` ($HOME/Library/Application Support) ?
|
||||
let mut config_dir = ::dirs::data_dir().unwrap();
|
||||
config_dir.push("Servo");
|
||||
config_dir
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
pub fn default_config_dir() -> PathBuf {
|
||||
let mut config_dir = match env::var_os("APPDATA") {
|
||||
Some(appdata_path) => PathBuf::from(appdata_path),
|
||||
None => {
|
||||
let mut dir = env::home_dir().unwrap();
|
||||
dir.push("Appdata");
|
||||
dir.push("Roaming");
|
||||
dir
|
||||
}
|
||||
};
|
||||
let mut config_dir = ::dirs::config_dir().unwrap();
|
||||
config_dir.push("Servo");
|
||||
config_dir
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
#[cfg(target_os = "android")]
|
||||
extern crate android_injected_glue;
|
||||
#[cfg(not(target_os = "android"))]
|
||||
extern crate dirs;
|
||||
extern crate embedder_traits;
|
||||
extern crate euclid;
|
||||
extern crate getopts;
|
||||
|
@ -17,8 +19,6 @@ extern crate rustc_serialize;
|
|||
extern crate servo_geometry;
|
||||
extern crate servo_url;
|
||||
extern crate url;
|
||||
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))]
|
||||
extern crate xdg;
|
||||
|
||||
pub mod basedir;
|
||||
#[allow(unsafe_code)] pub mod opts;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue