Просмотр исходного кода

create util module & create join_config_path function

ghassmo 5 лет назад
Родитель
Сommit
a19084ca10
2 измененных файлов с 15 добавлено и 0 удалено
  1. 1 0
      src/lib.rs
  2. 14 0
      src/util.rs

+ 1 - 0
src/lib.rs

@@ -21,6 +21,7 @@ pub mod tx;
 pub mod vm;
 pub mod vm_serial;
 pub mod wallet;
+pub mod util;
 
 pub use crate::bls_extensions::BlsStringConversion;
 pub use crate::error::{Error, Result};

+ 14 - 0
src/util.rs

@@ -0,0 +1,14 @@
+
+use crate::Error;
+use crate::Result;
+
+use std::path::PathBuf;
+
+pub fn join_config_path(file: &PathBuf) -> Result<PathBuf> {
+    let mut path = dirs::home_dir()
+        .ok_or(Error::PathNotFound)?
+        .as_path()
+        .join(".config/darkfi/");
+    path.push(file);
+    Ok(path)
+}