mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +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
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue