mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01: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
|
@ -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