Skip to content

Commit da70a78

Browse files
niklasad1dvdplm
authored andcommitted
Replace std::env::home_dir with dirs::home_dir (#9077)
`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
1 parent 1803c0f commit da70a78

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

path/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[package]
22
name = "path"
3-
version = "0.1.0"
4-
authors = ["debris <[email protected]>"]
3+
version = "0.1.1"
4+
authors = ["Parity Technologies <[email protected]>"]
5+
license = "GPL3"
56

67
[dependencies]
8+
dirs = "1.0.2"

path/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@
1515
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
1616

1717
//! Path utilities
18+
extern crate dirs;
19+
1820
use std::path::Path;
1921
use std::path::PathBuf;
2022

2123
#[cfg(target_os = "macos")]
2224
/// Get the config path for application `name`.
2325
/// `name` should be capitalized, e.g. `"Ethereum"`, `"Parity"`.
2426
pub fn config_path(name: &str) -> PathBuf {
25-
let mut home = ::std::env::home_dir().expect("Failed to get home dir");
27+
let mut home = dirs::home_dir().expect("Failed to get home dir");
2628
home.push("Library");
2729
home.push(name);
2830
home
@@ -32,7 +34,7 @@ pub fn config_path(name: &str) -> PathBuf {
3234
/// Get the config path for application `name`.
3335
/// `name` should be capitalized, e.g. `"Ethereum"`, `"Parity"`.
3436
pub fn config_path(name: &str) -> PathBuf {
35-
let mut home = ::std::env::home_dir().expect("Failed to get home dir");
37+
let mut home = dirs::home_dir().expect("Failed to get home dir");
3638
home.push("AppData");
3739
home.push("Roaming");
3840
home.push(name);
@@ -43,7 +45,7 @@ pub fn config_path(name: &str) -> PathBuf {
4345
/// Get the config path for application `name`.
4446
/// `name` should be capitalized, e.g. `"Ethereum"`, `"Parity"`.
4547
pub fn config_path(name: &str) -> PathBuf {
46-
let mut home = ::std::env::home_dir().expect("Failed to get home dir");
48+
let mut home = dirs::home_dir().expect("Failed to get home dir");
4749
home.push(format!(".{}", name.to_lowercase()));
4850
home
4951
}

0 commit comments

Comments
 (0)