2026-08-24 01:22:00 +03:00
|
|
|
use crate::notification::NotificationData;
|
|
|
|
|
use crate::notification::NotificationData::PermissionDenied;
|
2026-08-25 12:04:07 +03:00
|
|
|
use std::fs;
|
|
|
|
|
use std::path::PathBuf;
|
2026-08-24 01:22:00 +03:00
|
|
|
|
|
|
|
|
pub fn app_data_dir() -> PathBuf {
|
2026-08-24 23:27:24 +03:00
|
|
|
let mut dir = dirs::data_dir().expect("Unsupported OS");
|
2026-08-24 01:22:00 +03:00
|
|
|
dir.push("jap_learn");
|
|
|
|
|
if !dir.exists() {
|
2026-08-24 23:27:24 +03:00
|
|
|
fs::create_dir_all(dir.clone()).expect("Unable to create directory");
|
2026-08-24 01:22:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dir
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn db_path() -> PathBuf {
|
2026-08-25 12:04:07 +03:00
|
|
|
app_data_dir().join("data.db")
|
2026-08-24 01:22:00 +03:00
|
|
|
}
|
|
|
|
|
pub fn temp_db_path() -> PathBuf {
|
2026-08-25 12:04:07 +03:00
|
|
|
app_data_dir().join("data.db.tmp")
|
2026-08-24 01:22:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn temp_import_path() -> PathBuf {
|
|
|
|
|
app_data_dir().join("import")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn db_meta_path() -> PathBuf {
|
|
|
|
|
app_data_dir().join("data.meta")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn voice_dir() -> Result<PathBuf, NotificationData> {
|
|
|
|
|
let directory = app_data_dir().join("voice");
|
|
|
|
|
if !directory.exists() {
|
|
|
|
|
fs::create_dir_all(directory.clone()).map_err(|_| PermissionDenied)?;
|
|
|
|
|
}
|
|
|
|
|
Ok(directory)
|
2026-08-25 12:04:07 +03:00
|
|
|
}
|