Skip to main content

siglus_scene_vm/
app_path.rs

1use std::ffi::OsStr;
2use std::path::PathBuf;
3
4use anyhow::{anyhow, Context, Result};
5
6pub fn resolve_app_base_path() -> Result<PathBuf> {
7    if std::env::var_os("SIG_TEST").as_deref() == Some(OsStr::new("1")) {
8        let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
9        return Ok(manifest_dir.join("testcase"));
10    }
11
12    let exe_path = std::env::current_exe().context("resolve current executable path")?;
13    let exe_dir = exe_path
14        .parent()
15        .ok_or_else(|| anyhow!("executable path has no parent: {}", exe_path.display()))?;
16    Ok(exe_dir.to_path_buf())
17}