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

Deletes the requested file. If the file does not exist, this function will return true.

Arguments

  • path - The file path

Example

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

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

    let path = Path::new(file_path);
    assert!(path.exists());

    let deleted = file::delete_ignore_error(file_path);
    assert!(deleted);

    assert!(!path.exists());
}