forked from mirrors/gecko-dev
<!-- Please describe your changes on the following line: --> I removed `default_data_dir()` and `default_cache_dir()` from `components/config/basedir.rs` because they were never called. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes do not require tests because they only remove untested code <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 0eb8b1f4c0736ec25dc391d119c03d1b49644d81 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : 79de14ce6be480d377015a59a2d45dd99e7a5ef3
56 lines
1.8 KiB
Rust
56 lines
1.8 KiB
Rust
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
//! Contains routines for retrieving default config directories.
|
|
//! For linux based platforms, it uses the XDG base directory spec but provides
|
|
//! similar abstractions for non-linux platforms.
|
|
|
|
#[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()
|
|
}
|
|
|
|
#[cfg(target_os = "android")]
|
|
#[allow(unsafe_code)]
|
|
pub fn default_config_dir() -> PathBuf {
|
|
let dir = unsafe {
|
|
CStr::from_ptr((*android_injected_glue::get_app().activity).externalDataPath)
|
|
};
|
|
PathBuf::from(dir.to_str().unwrap())
|
|
}
|
|
|
|
#[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");
|
|
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
|
|
}
|
|
};
|
|
config_dir.push("Servo");
|
|
config_dir
|
|
}
|