Skip to content

Commit

Permalink
Replace std::env::home_dir with dirs::home_dir (#9077)
Browse files Browse the repository at this point in the history
`std::env::home_dir` is deprecated but will probably take a while until
it is deprecated on stable. For more info see rust-lang/rust#51656
  • Loading branch information
niklasad1 authored and dvdplm committed Jul 9, 2018
1 parent 1803c0f commit da70a78
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
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 <[email protected]>"]
version = "0.1.1"
authors = ["Parity Technologies <[email protected]>"]
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

0 comments on commit da70a78

Please sign in to comment.