#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
}

View file

@ -184,7 +184,7 @@ pub fn add_user_prefs() {
init_user_prefs(&mut path);
}
None => {
let mut path = default_config_dir().unwrap();
let mut path = default_config_dir();
if path.join("prefs.json").exists() {
init_user_prefs(&mut path);
}

View file

@ -56,7 +56,7 @@ fn test_default_config_dir_create_read_write() {
\"shell.homepage\": \"https://google.com\"\
}";
let mut expected_json = String::new();
let config_path = basedir::default_config_dir().unwrap();
let config_path = basedir::default_config_dir();
if !config_path.exists() {
fs::create_dir_all(&config_path).unwrap();

View file

@ -258,7 +258,7 @@ fn args() -> Vec<String> {
use std::fs::File;
use std::io::{BufRead, BufReader};
let mut params_file = config::basedir::default_config_dir().unwrap();
let mut params_file = config::basedir::default_config_dir();
params_file.push("android_params");
match File::open(params_file.to_str().unwrap()) {
Ok(f) => {