mirror of
https://github.com/Vomitblood/stort.git
synced 2025-03-27 01:01:00 +08:00
21 lines
753 B
Rust
21 lines
753 B
Rust
pub fn get_app_data_dir() -> Result<std::path::PathBuf, String> {
|
|
// attempt to get the app data directory
|
|
match tauri::api::path::data_dir() {
|
|
Some(data_dir) => {
|
|
let app_data_dir = data_dir.join("stort/");
|
|
// ensure the directory exists
|
|
if !app_data_dir.exists() {
|
|
// attempt to create the directory
|
|
std::fs::create_dir_all(&app_data_dir).map_err(|e| {
|
|
format!(
|
|
"Failed to create app data directory {:?}: {}",
|
|
app_data_dir, e
|
|
)
|
|
})?;
|
|
}
|
|
Ok(app_data_dir)
|
|
}
|
|
None => Err("Failed to get app data directory".to_string()),
|
|
}
|
|
}
|