burncloud-common 0.1.0

Common utilities and types for the BurnCloud platform
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::fs;
use std::path::Path;
use anyhow::Result;

pub fn ensure_dir_exists(path: &str) -> Result<()> {
    if !Path::new(path).exists() {
        fs::create_dir_all(path)?;
    }
    Ok(())
}

pub fn get_home_dir() -> String {
    dirs::home_dir()
        .unwrap_or_else(|| std::env::current_dir().unwrap())
        .to_string_lossy()
        .to_string()
}