13 lines
406 B
Rust
13 lines
406 B
Rust
use std::path::PathBuf;
|
|
|
|
/// Returns the `data/` directory next to the running executable.
|
|
/// Creates it if it does not exist.
|
|
pub fn data_dir() -> PathBuf {
|
|
let exe = std::env::current_exe().unwrap_or_else(|_| PathBuf::from("."));
|
|
let dir = exe.parent().unwrap_or_else(|| std::path::Path::new(".")).join("data");
|
|
if !dir.exists() {
|
|
std::fs::create_dir_all(&dir).ok();
|
|
}
|
|
dir
|
|
}
|