use std::path::PathBuf;
#[cfg(feature = "istmo")]
#[must_use]
pub fn config_base_dir() -> Option<PathBuf> {
Some(istmo_core::path::config_dir().to_path_buf())
}
#[cfg(all(not(feature = "istmo"), target_os = "windows"))]
#[must_use]
pub fn config_base_dir() -> Option<PathBuf> {
std::env::var_os("APPDATA").map(PathBuf::from)
}
#[cfg(all(not(feature = "istmo"), target_os = "macos"))]
#[must_use]
pub fn config_base_dir() -> Option<PathBuf> {
home_dir().map(|h| h.join("Library").join("Application Support"))
}
#[cfg(all(
not(feature = "istmo"),
not(any(target_os = "windows", target_os = "macos"))
))]
#[must_use]
pub fn config_base_dir() -> Option<PathBuf> {
std::env::var_os("XDG_CONFIG_HOME")
.map(PathBuf::from)
.or_else(|| home_dir().map(|h| h.join(".config")))
}
#[cfg(feature = "istmo")]
#[must_use]
pub fn data_base_dir() -> Option<PathBuf> {
Some(istmo_core::path::data_dir().to_path_buf())
}
#[cfg(all(not(feature = "istmo"), target_os = "windows"))]
#[must_use]
pub fn data_base_dir() -> Option<PathBuf> {
std::env::var_os("LOCALAPPDATA").map(PathBuf::from)
}
#[cfg(all(not(feature = "istmo"), target_os = "macos"))]
#[must_use]
pub fn data_base_dir() -> Option<PathBuf> {
home_dir().map(|h| h.join("Library").join("Application Support"))
}
#[cfg(all(
not(feature = "istmo"),
not(any(target_os = "windows", target_os = "macos"))
))]
#[must_use]
pub fn data_base_dir() -> Option<PathBuf> {
std::env::var_os("XDG_DATA_HOME")
.map(PathBuf::from)
.or_else(|| home_dir().map(|h| h.join(".local").join("share")))
}
#[cfg(feature = "istmo")]
#[must_use]
pub fn app_config_dir(_app_name: &str) -> Option<PathBuf> {
Some(istmo_core::path::config_dir().to_path_buf())
}
#[cfg(not(feature = "istmo"))]
#[must_use]
pub fn app_config_dir(app_name: &str) -> Option<PathBuf> {
config_base_dir().map(|d| d.join(app_name))
}
#[cfg(feature = "istmo")]
#[must_use]
pub fn app_data_dir(_app_name: &str) -> Option<PathBuf> {
Some(istmo_core::path::data_dir().to_path_buf())
}
#[cfg(not(feature = "istmo"))]
#[must_use]
pub fn app_data_dir(app_name: &str) -> Option<PathBuf> {
data_base_dir().map(|d| d.join(app_name))
}
#[cfg(feature = "istmo")]
#[must_use]
pub fn app_cache_dir(_app_name: &str) -> Option<PathBuf> {
Some(istmo_core::path::cache_dir().to_path_buf())
}
#[cfg(feature = "istmo")]
#[must_use]
pub fn app_state_dir(_app_name: &str) -> Option<PathBuf> {
Some(istmo_core::path::state_dir().to_path_buf())
}
#[cfg(not(feature = "istmo"))]
fn home_dir() -> Option<PathBuf> {
std::env::var_os("HOME").map(PathBuf::from)
}