safer_remove_file

Function safer_remove_file 

Source
pub fn safer_remove_file<'a>(
    file_path: &SPath,
    options: impl Into<SaferRemoveOptions<'a>>,
) -> Result<bool>
Expand description

Safely deletes a file if it passes safety checks.

Safety checks (based on options):

  • If restrict_to_current_dir is true, the file path must be below the current directory
  • If must_contain_any is set, the path must contain at least one of the specified patterns
  • If must_contain_all is set, the path must contain all of the specified patterns

Returns Ok(true) if the file was deleted, Ok(false) if it didn’t exist. Returns an error if safety checks fail or deletion fails.