use std::path::PathBuf;
pub fn default_cache_dir() -> PathBuf {
if let Ok(custom) = std::env::var("HCLI_CACHE_DIR") {
return PathBuf::from(custom);
}
let base = if cfg!(target_os = "macos") {
dirs::home_dir()
.map(|h| h.join("Library").join("Caches"))
.unwrap_or_else(|| PathBuf::from(".cache"))
} else if cfg!(target_os = "windows") {
dirs::cache_dir().unwrap_or_else(|| PathBuf::from(".cache"))
} else {
std::env::var("XDG_CACHE_HOME")
.ok()
.map(PathBuf::from)
.unwrap_or_else(|| {
dirs::home_dir()
.unwrap_or_else(|| PathBuf::from("."))
.join(".cache")
})
};
base.join("hex-rays").join("hcli")
}
pub fn cache_dir(key: &str) -> PathBuf {
let dir = default_cache_dir().join(key);
let _ = std::fs::create_dir_all(&dir);
dir
}