Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace std::env::home_dir with dirs::home_dir (#9077) #3

Merged
merged 1 commit into from
Jul 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions path/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[package]
name = "path"
version = "0.1.0"
authors = ["debris <marek.kotewicz@gmail.com>"]
version = "0.1.1"
authors = ["Parity Technologies <admin@parity.io>"]
license = "GPL3"

[dependencies]
dirs = "1.0.2"
8 changes: 5 additions & 3 deletions path/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

//! Path utilities
extern crate dirs;

use std::path::Path;
use std::path::PathBuf;

#[cfg(target_os = "macos")]
/// Get the config path for application `name`.
/// `name` should be capitalized, e.g. `"Ethereum"`, `"Parity"`.
pub fn config_path(name: &str) -> PathBuf {
let mut home = ::std::env::home_dir().expect("Failed to get home dir");
let mut home = dirs::home_dir().expect("Failed to get home dir");
home.push("Library");
home.push(name);
home
Expand All @@ -32,7 +34,7 @@ pub fn config_path(name: &str) -> PathBuf {
/// Get the config path for application `name`.
/// `name` should be capitalized, e.g. `"Ethereum"`, `"Parity"`.
pub fn config_path(name: &str) -> PathBuf {
let mut home = ::std::env::home_dir().expect("Failed to get home dir");
let mut home = dirs::home_dir().expect("Failed to get home dir");
home.push("AppData");
home.push("Roaming");
home.push(name);
Expand All @@ -43,7 +45,7 @@ pub fn config_path(name: &str) -> PathBuf {
/// Get the config path for application `name`.
/// `name` should be capitalized, e.g. `"Ethereum"`, `"Parity"`.
pub fn config_path(name: &str) -> PathBuf {
let mut home = ::std::env::home_dir().expect("Failed to get home dir");
let mut home = dirs::home_dir().expect("Failed to get home dir");
home.push(format!(".{}", name.to_lowercase()));
home
}
Expand Down