-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa9f50a
commit b4885fe
Showing
13 changed files
with
170 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* 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. | ||
|
||
extern crate xdg; | ||
|
||
use std::env; | ||
use std::fs; | ||
use std::path::PathBuf; | ||
|
||
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "windows")))] | ||
pub fn default_config_dir() -> Option<PathBuf> { | ||
let xdg_dirs = xdg::BaseDirectories::with_profile("servo", "default").unwrap(); | ||
let config_dir = xdg_dirs.get_config_home(); | ||
Some(config_dir) | ||
} | ||
|
||
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "windows")))] | ||
pub fn default_data_dir() -> Option<PathBuf> { | ||
let xdg_dirs = xdg::BaseDirectories::with_profile("servo", "default").unwrap(); | ||
let data_dir = xdg_dirs.get_data_home(); | ||
Some(data_dir) | ||
} | ||
|
||
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "windows")))] | ||
pub fn default_cache_dir() -> Option<PathBuf> { | ||
let xdg_dirs = xdg::BaseDirectories::with_profile("servo", "default").unwrap(); | ||
let cache_dir = xdg_dirs.get_cache_home(); | ||
Some(cache_dir) | ||
} | ||
|
||
#[cfg(target_os = "macos")] | ||
pub fn default_config_dir() -> Option<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) | ||
} | ||
|
||
#[cfg(target_os = "windows")] | ||
pub fn default_config_dir() -> Option<PathBuf> { | ||
let mut config_dir = match env::var("APPDATA") { | ||
Ok(appdata_path) => PathBuf::from(appdata_path), | ||
Err(_) => { let mut dir = env::home_dir().unwrap(); | ||
dir.push("Appdata"); | ||
dir.push("Roaming"); | ||
dir | ||
} | ||
}; | ||
config_dir.push("Servo"); | ||
Some(config_dir) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ doctest = false | |
|
||
[dependencies] | ||
util = {path = "../../../components/util"} | ||
|
Oops, something went wrong.