trifid/tfclient/src/dirs.rs

50 lines
1.3 KiB
Rust

use std::path::PathBuf;
#[cfg(any(target_os = "linux", target_os = "netbsd"))]
pub fn config_base() -> PathBuf {
PathBuf::from("/etc/tfclient")
}
#[cfg(target_os = "windows")]
pub fn config_base() -> PathBuf {
PathBuf::from("C:\\Program Data\\e3team\\tfclient")
}
#[cfg(target_os = "macos")]
pub fn config_base() -> PathBuf {
PathBuf::from("/Library/Application Support/e3team/tfclient")
}
#[cfg(target_os = "ios")]
compile_error!("tfclient cannot be compiled for iOS");
#[cfg(target_os = "android")]
compile_error!("tfclient cannot be compiled for Android");
#[cfg(target_os = "freebsd")]
pub fn config_base() -> PathBuf {
PathBuf::from("/etc/tfclient")
}
#[cfg(target_os = "dragonfly")]
compile_error!("tfclient cannot be compiled for dragonfly");
#[cfg(target_os = "openbsd")]
compile_error!("tfclient cannot be compiled for openbsd");
pub fn config_dir(instance: &str) -> PathBuf {
config_base().join(format!("{}/", instance))
}
pub fn tfclient_toml(instance: &str) -> PathBuf {
config_base()
.join(format!("{}/", instance))
.join("tfclient.toml")
}
pub fn tfdata_toml(instance: &str) -> PathBuf {
config_base()
.join(format!("{}/", instance))
.join("tfdata.toml")
}
pub fn nebula_yml(instance: &str) -> PathBuf {
config_base()
.join(format!("{}/", instance))
.join("nebula.yml")
}