move helper functions to platform module
This commit is contained in:
parent
2e12a2db50
commit
268e8f5a64
@ -245,7 +245,7 @@ fn home() -> PathBuf {
|
|||||||
|
|
||||||
/// Geth path
|
/// Geth path
|
||||||
pub fn geth(testnet: bool) -> PathBuf {
|
pub fn geth(testnet: bool) -> PathBuf {
|
||||||
let mut base = geth_base();
|
let mut base = platform::geth_base();
|
||||||
if testnet {
|
if testnet {
|
||||||
base.push("testnet");
|
base.push("testnet");
|
||||||
}
|
}
|
||||||
@ -255,14 +255,16 @@ pub fn geth(testnet: bool) -> PathBuf {
|
|||||||
|
|
||||||
/// Parity path for specific chain
|
/// Parity path for specific chain
|
||||||
pub fn parity(chain: &str) -> PathBuf {
|
pub fn parity(chain: &str) -> PathBuf {
|
||||||
let mut base = parity_base();
|
let mut base = platform::parity_base();
|
||||||
base.push(chain);
|
base.push(chain);
|
||||||
base
|
base
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod platform {
|
||||||
|
use std::path::PathBuf;
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
fn parity_base() -> PathBuf {
|
pub fn parity_base() -> PathBuf {
|
||||||
let mut home = home();
|
let mut home = super::home();
|
||||||
home.push("Library");
|
home.push("Library");
|
||||||
home.push("Application Support");
|
home.push("Application Support");
|
||||||
home.push("io.parity.ethereum");
|
home.push("io.parity.ethereum");
|
||||||
@ -271,8 +273,8 @@ fn parity_base() -> PathBuf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn parity_base() -> PathBuf {
|
pub fn parity_base() -> PathBuf {
|
||||||
let mut home = home();
|
let mut home = super::home();
|
||||||
home.push("AppData");
|
home.push("AppData");
|
||||||
home.push("Roaming");
|
home.push("Roaming");
|
||||||
home.push("Parity");
|
home.push("Parity");
|
||||||
@ -282,8 +284,8 @@ fn parity_base() -> PathBuf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "macos", windows)))]
|
#[cfg(not(any(target_os = "macos", windows)))]
|
||||||
fn parity_base() -> PathBuf {
|
pub fn parity_base() -> PathBuf {
|
||||||
let mut home = home();
|
let mut home = super::home();
|
||||||
home.push(".local");
|
home.push(".local");
|
||||||
home.push("share");
|
home.push("share");
|
||||||
home.push("io.parity.ethereum");
|
home.push("io.parity.ethereum");
|
||||||
@ -292,16 +294,16 @@ fn parity_base() -> PathBuf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
fn geth_base() -> PathBuf {
|
pub fn geth_base() -> PathBuf {
|
||||||
let mut home = home();
|
let mut home = super::home();
|
||||||
home.push("Library");
|
home.push("Library");
|
||||||
home.push("Ethereum");
|
home.push("Ethereum");
|
||||||
home
|
home
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn geth_base() -> PathBuf {
|
pub fn geth_base() -> PathBuf {
|
||||||
let mut home = home();
|
let mut home = super::home();
|
||||||
home.push("AppData");
|
home.push("AppData");
|
||||||
home.push("Roaming");
|
home.push("Roaming");
|
||||||
home.push("Ethereum");
|
home.push("Ethereum");
|
||||||
@ -309,11 +311,13 @@ fn geth_base() -> PathBuf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "macos", windows)))]
|
#[cfg(not(any(target_os = "macos", windows)))]
|
||||||
fn geth_base() -> PathBuf {
|
pub fn geth_base() -> PathBuf {
|
||||||
let mut home = home();
|
let mut home = super::home();
|
||||||
home.push(".ethereum");
|
home.push(".ethereum");
|
||||||
home
|
home
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::Directories;
|
use super::Directories;
|
||||||
|
Loading…
Reference in New Issue
Block a user