diff options
author | Simon Sapin <simon.sapin@exyr.org> | 2018-07-18 11:25:08 +0200 |
---|---|---|
committer | Simon Sapin <simon.sapin@exyr.org> | 2018-07-18 11:25:30 +0200 |
commit | e397ca06d84ee2b0c9167a466c199d72e23abc48 (patch) | |
tree | ace56e122f729b377775d8f370e788cb76e13f57 /components/config/basedir.rs | |
parent | 88664912ed6934640516994b17dfd50fd444040e (diff) | |
download | servo-e397ca06d84ee2b0c9167a466c199d72e23abc48.tar.gz servo-e397ca06d84ee2b0c9167a466c199d72e23abc48.zip |
Avoid use of deprecated (and buggy) std::env::home_dir
Diffstat (limited to 'components/config/basedir.rs')
-rw-r--r-- | components/config/basedir.rs | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/components/config/basedir.rs b/components/config/basedir.rs index 2f634448b34..f3dd0ca7f67 100644 --- a/components/config/basedir.rs +++ b/components/config/basedir.rs @@ -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 } |