cairo_lang_filesystem/
detect.rs1use std::path::PathBuf;
2
3pub fn detect_corelib() -> Option<PathBuf> {
4 for (base, up_options) in [
5 (std::env::var("CARGO_MANIFEST_DIR").ok().map(PathBuf::from), 1..=2),
8 (std::env::current_exe().ok(), 2..=4),
10 (std::env::current_dir().ok(), 0..=0),
12 ] {
13 let Some(base) = base else { continue };
14 for up in up_options {
15 let mut path = base.clone();
16 for _ in 0..up {
17 path.pop();
18 }
19 path.push("corelib");
20 path.push("src");
21 if path.exists() {
22 return Some(path);
23 }
24 }
25 }
26 None
27}