pub fn ensure_exists<T: AsPath + ?Sized>(path: &T) -> FsIOResult<()>
Expand description

Ensures the provided path leads to an existing file. If the file does not exist, this function will create an emtpy file.

Arguments

  • path - The file path

Example

use crate::fsio::file;
use std::path::Path;

fn main() {
    let result = file::ensure_exists("./target/__test/file_test/dir1/dir2/file.txt");
    assert!(result.is_ok());

    let path = Path::new("./target/__test/file_test/dir1/dir2/file.txt");
    assert!(path.exists());
}