blob: af993e3852ff96de27c2a2eb4d3138a1d9ca55be (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/* 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 https://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.
use std::path::PathBuf;
#[cfg(all(
unix,
not(target_os = "macos"),
not(target_os = "ios"),
not(target_os = "android")
))]
pub fn default_config_dir() -> Option<PathBuf> {
let mut config_dir = ::dirs::config_dir().unwrap();
config_dir.push("servo");
config_dir.push("default");
Some(config_dir)
}
#[cfg(target_os = "android")]
pub fn default_config_dir() -> Option<PathBuf> {
None
}
#[cfg(target_os = "macos")]
pub fn default_config_dir() -> Option<PathBuf> {
// 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");
Some(config_dir)
}
#[cfg(all(target_os = "windows", not(feature = "uwp")))]
pub fn default_config_dir() -> Option<PathBuf> {
let mut config_dir = ::dirs::config_dir().unwrap();
config_dir.push("Servo");
Some(config_dir)
}
#[cfg(all(target_os = "windows", feature = "uwp"))]
pub fn default_config_dir() -> Option<PathBuf> {
None
}
|