Revert "Replace std::env::home_dir with dirs::home_dir (#9077)" (#9097)

* Revert "Replace `std::env::home_dir` with `dirs::home_dir` (#9077)"

This reverts commit 7e779327eb.

* Restore some of the changes

* Update parity-common
This commit is contained in:
Pierre Krieger
2018-07-12 13:45:02 +02:00
committed by 5chdn
parent 3f53e0e8b1
commit f2ea66fc05
5 changed files with 30 additions and 46 deletions

View File

@@ -15,11 +15,12 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
//! Directory helper functions
use std::env;
/// Replaces `$HOME` str with home directory path.
pub fn replace_home(base: &str, arg: &str) -> String {
// the $HOME directory on mac os should be `~/Library` or `~/Library/Application Support`
let r = arg.replace("$HOME", ::dirs::home_dir().unwrap().to_str().unwrap());
let r = arg.replace("$HOME", env::home_dir().unwrap().to_str().unwrap());
let r = r.replace("$BASE", base);
r.replace("/", &::std::path::MAIN_SEPARATOR.to_string())
}

View File

@@ -18,12 +18,11 @@
//! Dir utilities for platform-specific operations
extern crate app_dirs;
extern crate dirs;
extern crate ethereum_types;
extern crate journaldb;
pub mod helpers;
use std::fs;
use std::{env, fs};
use std::path::{PathBuf, Path};
use ethereum_types::{H64, H256};
use journaldb::Algorithm;
@@ -32,8 +31,6 @@ use app_dirs::{AppInfo, get_app_root, AppDataType};
// re-export platform-specific functions
use platform::*;
pub use dirs::home_dir;
/// Platform-specific chains path for standard client - Windows only
#[cfg(target_os = "windows")] pub const CHAINS_PATH: &str = "$LOCAL/chains";
/// Platform-specific chains path for light client - Windows only
@@ -240,7 +237,7 @@ pub fn default_hypervisor_path() -> PathBuf {
/// Get home directory.
fn home() -> PathBuf {
dirs::home_dir().expect("Failed to get home dir")
env::home_dir().expect("Failed to get home dir")
}
/// Geth path
@@ -263,9 +260,9 @@ pub fn parity(chain: &str) -> PathBuf {
#[cfg(target_os = "macos")]
mod platform {
use std::path::PathBuf;
pub const AUTHOR: &'static str = "Parity";
pub const PRODUCT: &'static str = "io.parity.ethereum";
pub const PRODUCT_HYPERVISOR: &'static str = "io.parity.ethereum-updates";
pub const AUTHOR: &str = "Parity";
pub const PRODUCT: &str = "io.parity.ethereum";
pub const PRODUCT_HYPERVISOR: &str = "io.parity.ethereum-updates";
pub fn parity_base() -> PathBuf {
let mut home = super::home();
@@ -287,9 +284,9 @@ mod platform {
#[cfg(windows)]
mod platform {
use std::path::PathBuf;
pub const AUTHOR: &'static str = "Parity";
pub const PRODUCT: &'static str = "Ethereum";
pub const PRODUCT_HYPERVISOR: &'static str = "EthereumUpdates";
pub const AUTHOR: &str = "Parity";
pub const PRODUCT: &str = "Ethereum";
pub const PRODUCT_HYPERVISOR: &str = "EthereumUpdates";
pub fn parity_base() -> PathBuf {
let mut home = super::home();