use std::path::PathBuf;
pub fn home_dir() -> Option<PathBuf> {
#[cfg(target_os = "windows")]
{
std::env::var("USERPROFILE").ok().map(PathBuf::from)
}
#[cfg(not(target_os = "windows"))]
{
std::env::var("HOME").ok().map(PathBuf::from)
}
}
pub fn cache_dir() -> Option<PathBuf> {
#[cfg(target_os = "windows")]
{
std::env::var("LOCALAPPDATA").ok().map(PathBuf::from)
}
#[cfg(target_os = "macos")]
{
home_dir().map(|h| h.join("Library").join("Caches"))
}
#[cfg(not(any(target_os = "windows", target_os = "macos")))]
{
std::env::var("XDG_CACHE_HOME")
.ok()
.map(PathBuf::from)
.or_else(|| home_dir().map(|h| h.join(".cache")))
}
}
pub fn data_local_dir() -> Option<PathBuf> {
#[cfg(target_os = "windows")]
{
std::env::var("LOCALAPPDATA").ok().map(PathBuf::from)
}
#[cfg(not(target_os = "windows"))]
{
cache_dir()
}
}