From 5326d48f6e0a88ad42005c39b73f7baaf91c9b86 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Wed, 28 Dec 2022 13:15:10 +0100 Subject: added devdir; better config dir --- src/lib.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 971f544..17ad6b9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,7 @@ pub mod db; pub mod error; pub mod files; -use std::io::{Error, ErrorKind}; +use std::{io::{Error, ErrorKind}, path::Path}; pub use apis::*; pub use commands::*; @@ -33,3 +33,17 @@ impl Modloader { } } } + +pub fn devdir(path: &str) -> String { + let p = Path::new(path); + let dev = std::env::var("DEV"); + let lvl = match dev { + Ok(dev) => dev.parse::().unwrap(), + Err(..) => 0, + }; + if lvl >= 1 { + format!("./dev/{}", p.file_name().unwrap().to_str().unwrap()) + } else { + String::from(path) + } +} -- cgit v1.2.3