global: snapshot

This commit is contained in:
nym21
2025-03-10 11:42:15 +01:00
parent f9f7172702
commit 9428beeae5
44 changed files with 1348 additions and 581 deletions

View File

@@ -0,0 +1,3 @@
pub trait CheckedSub<Rhs = Self>: Sized {
fn checked_sub(self, rhs: Rhs) -> Option<Self>;
}

View File

@@ -1,7 +1,9 @@
mod checked_sub;
mod paths;
mod pause;
mod rlimit;
pub use checked_sub::*;
pub use paths::*;
pub use pause::*;
pub use rlimit::*;

View File

@@ -1,4 +1,7 @@
use std::path::{Path, PathBuf};
use std::{
env,
path::{Path, PathBuf},
};
pub fn path_dot_brk() -> PathBuf {
let home = std::env::var("HOME").unwrap();
@@ -8,3 +11,26 @@ pub fn path_dot_brk() -> PathBuf {
pub fn path_dot_brk_log() -> PathBuf {
path_dot_brk().join("log")
}
pub fn default_brk() -> PathBuf {
path_dot_brk()
}
pub fn default_bitcoin_path() -> PathBuf {
if env::consts::OS == "macos" {
default_mac_bitcoin_path()
} else {
default_linux_bitcoin_path()
}
}
fn default_linux_bitcoin_path() -> PathBuf {
Path::new(&std::env::var("HOME").unwrap()).join(".bitcoin")
}
fn default_mac_bitcoin_path() -> PathBuf {
Path::new(&std::env::var("HOME").unwrap())
.join("Library")
.join("Application Support")
.join("Bitcoin")
}