20 lines
504 B
Rust
20 lines
504 B
Rust
|
use anyhow::{anyhow, Result};
|
||
|
use shadow_rs::{is_debug, shadow};
|
||
|
|
||
|
shadow!(build);
|
||
|
|
||
|
pub fn get_static_dir<S: AsRef<str>>(dir: S) -> Result<std::path::PathBuf> {
|
||
|
let cwd = std::env::current_exe()?.parent().unwrap().to_path_buf();
|
||
|
let base_path = if is_debug() {
|
||
|
cwd.join("../../tmp/static")
|
||
|
} else {
|
||
|
cwd
|
||
|
};
|
||
|
let result = base_path.join(dir.as_ref());
|
||
|
if result.exists() {
|
||
|
Ok(result)
|
||
|
} else {
|
||
|
Err(anyhow!("Path {result:?} doesn't exist."))
|
||
|
}
|
||
|
}
|