#20174 removed the option and unwrap

This commit is contained in:
Andrei Cristian Petcu 2018-03-02 20:21:24 +02:00
parent 476a0764f5
commit 415c43e226
4 changed files with 11 additions and 12 deletions

View file

@ -17,19 +17,18 @@ use std::path::PathBuf;
use xdg;
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))]
pub fn default_config_dir() -> Option<PathBuf> {
pub fn default_config_dir() -> PathBuf {
let xdg_dirs = xdg::BaseDirectories::with_profile("servo", "default").unwrap();
let config_dir = xdg_dirs.get_config_home();
Some(config_dir)
xdg_dirs.get_config_home()
}
#[cfg(target_os = "android")]
#[allow(unsafe_code)]
pub fn default_config_dir() -> Option<PathBuf> {
pub fn default_config_dir() -> PathBuf {
let dir = unsafe {
CStr::from_ptr((*android_injected_glue::get_app().activity).externalDataPath)
};
Some(PathBuf::from(dir.to_str().unwrap()))
PathBuf::from(dir.to_str().unwrap())
}
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))]
@ -67,16 +66,16 @@ pub fn default_cache_dir() -> Option<PathBuf> {
}
#[cfg(target_os = "macos")]
pub fn default_config_dir() -> Option<PathBuf> {
pub fn default_config_dir() -> PathBuf {
let mut config_dir = env::home_dir().unwrap();
config_dir.push("Library");
config_dir.push("Application Support");
config_dir.push("Servo");
Some(config_dir)
config_dir
}
#[cfg(target_os = "windows")]
pub fn default_config_dir() -> Option<PathBuf> {
pub fn default_config_dir() -> PathBuf {
let mut config_dir = match env::var_os("APPDATA") {
Some(appdata_path) => PathBuf::from(appdata_path),
None => {
@ -87,5 +86,5 @@ pub fn default_config_dir() -> Option<PathBuf> {
}
};
config_dir.push("Servo");
Some(config_dir)
config_dir
}