#![doc = include_str!("../README.md")]
use std::path::PathBuf;
pub fn minecraft_dir() -> Option<PathBuf> {
let env_var = home_env_var();
let home = std::env::var(env_var).ok()?;
let path = PathBuf::from(home).join(minecraft_dir_relative());
Some(path)
}
pub fn home_env_var() -> &'static str {
#[cfg(target_os = "windows")]
{
"APPDATA"
}
#[cfg(target_os = "macos")]
{
"HOME"
}
#[cfg(target_os = "linux")]
{
"HOME"
}
#[cfg(not(any(target_os = "windows", target_os = "macos", target_os = "linux")))]
{
"HOME"
}
}
pub fn minecraft_dir_relative() -> &'static str {
#[cfg(target_os = "windows")]
{
".minecraft"
}
#[cfg(target_os = "macos")]
{
"Library/Application Support/minecraft"
}
#[cfg(target_os = "linux")]
{
".minecraft"
}
#[cfg(not(any(target_os = "windows", target_os = "macos", target_os = "linux")))]
{
".minecraft"
}
}