Skip to main content

burncloud_common/
utils.rs

1use anyhow::Result;
2use std::fs;
3use std::path::Path;
4
5pub fn ensure_dir_exists(path: &str) -> Result<()> {
6    if !Path::new(path).exists() {
7        fs::create_dir_all(path)?;
8    }
9    Ok(())
10}
11
12pub fn get_home_dir() -> String {
13    dirs::home_dir()
14        .unwrap_or_else(|| std::env::current_dir().unwrap())
15        .to_string_lossy()
16        .to_string()
17}