safe_create_file

Function safe_create_file 

Source
pub fn safe_create_file(path: &Path, allow_symlinks: bool) -> Result<File>
Expand description

Safely creates a file for writing

ยงExamples

use atlas_cli::utils::safe_create_file;
use std::path::Path;
use std::io::Write;

let path = Path::new("/tmp/new_file.txt");

match safe_create_file(&path, false) {
    Ok(mut file) => {
        file.write_all(b"Hello, World!").unwrap();
        println!("File created successfully");
    }
    Err(e) => eprintln!("Error creating file: {}", e),
}