Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Fix #6209 - introduce standalone dir crate #7383

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 26 additions & 21 deletions util/dir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ use bigint::hash::{H64, H256};
use journaldb::Algorithm;
use helpers::{replace_home, replace_home_and_local};
use app_dirs::{AppInfo, get_app_root, AppDataType};
// re-export platform-specific functions
use platform::*;

#[cfg(target_os = "macos")] const AUTHOR: &'static str = "Parity";
#[cfg(target_os = "macos")] const PRODUCT: &'static str = "io.parity.ethereum";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to grumble again, would you mind moving this constants to platform as well?

Expand Down Expand Up @@ -278,7 +280,7 @@ fn home() -> PathBuf {

/// Geth path
pub fn geth(testnet: bool) -> PathBuf {
let mut base = platform::geth_base();
let mut base = geth_base();
if testnet {
base.push("testnet");
}
Expand All @@ -288,14 +290,14 @@ pub fn geth(testnet: bool) -> PathBuf {

/// Parity path for specific chain
pub fn parity(chain: &str) -> PathBuf {
let mut base = platform::parity_base();
let mut base = parity_base();
base.push(chain);
base
}

#[cfg(target_os = "macos")]
mod platform {
use std::path::PathBuf;
#[cfg(target_os = "macos")]
pub fn parity_base() -> PathBuf {
let mut home = super::home();
home.push("Library");
Expand All @@ -305,45 +307,48 @@ mod platform {
home
}

#[cfg(windows)]
pub fn parity_base() -> PathBuf {
pub fn geth_base() -> PathBuf {
let mut home = super::home();
home.push("AppData");
home.push("Roaming");
home.push("Parity");
home.push("Library");
home.push("Ethereum");
home.push("keys");
home
}
}

#[cfg(not(any(target_os = "macos", windows)))]
#[cfg(windows)]
mod platform {
use std::path::PathBuf;
pub fn parity_base() -> PathBuf {
let mut home = super::home();
home.push(".local");
home.push("share");
home.push("io.parity.ethereum");
home.push("AppData");
home.push("Roaming");
home.push("Parity");
home.push("Ethereum");
home.push("keys");
home
}

#[cfg(target_os = "macos")]
pub fn geth_base() -> PathBuf {
let mut home = super::home();
home.push("Library");
home.push("AppData");
home.push("Roaming");
home.push("Ethereum");
home
}
}

#[cfg(windows)]
pub fn geth_base() -> PathBuf {
#[cfg(not(any(target_os = "macos", windows)))]
mod platform {
use std::path::PathBuf;
pub fn parity_base() -> PathBuf {
let mut home = super::home();
home.push("AppData");
home.push("Roaming");
home.push("Ethereum");
home.push(".local");
home.push("share");
home.push("io.parity.ethereum");
home.push("keys");
home
}

#[cfg(not(any(target_os = "macos", windows)))]
pub fn geth_base() -> PathBuf {
let mut home = super::home();
home.push(".ethereum");
Expand Down