[−][src]Function fsio::file::ensure_exists
pub fn ensure_exists<T: AsPath + ?Sized>(path: &T) -> Result<(), FsIOError>
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
extern crate fsio; 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()); }