()
| 1 | use std::path::PathBuf; |
| 2 | |
| 3 | pub fn get_data_path() -> PathBuf { |
| 4 | use std::env; |
| 5 | |
| 6 | // Check if COSDATA_HOME is set (installed mode) |
| 7 | if let Ok(home) = env::var("COSDATA_HOME") { |
| 8 | return PathBuf::from(home).join("data"); |
| 9 | } |
| 10 | |
| 11 | // Check if running inside a Cargo-built target folder |
| 12 | if let Ok(current_exe) = env::current_exe() { |
| 13 | if let Some(parent) = current_exe.parent() { |
| 14 | if parent.ends_with("debug") || parent.ends_with("release") { |
| 15 | return PathBuf::from("./data"); // Local development mode (within repo) |
| 16 | } |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | // Default fallback (shouldn't happen often) |
| 21 | PathBuf::from(env::var("HOME").unwrap()).join("cosdata/data") |
| 22 | } |
| 23 | |
| 24 | pub fn get_config_path() -> PathBuf { |
| 25 | use std::env; |
no outgoing calls
no test coverage detected