MCPcopy Create free account
hub / github.com/cosdata/cosdata / get_data_path

Function get_data_path

src/models/paths.rs:3–22  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1use std::path::PathBuf;
2
3pub 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
24pub fn get_config_path() -> PathBuf {
25 use std::env;

Callers 4

newMethod · 0.85
get_pathMethod · 0.85
get_collections_pathFunction · 0.85
get_app_envFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected