try_remove_file

Function try_remove_file 

Source
pub fn try_remove_file(path: impl AsRef<Path>) -> Result<()>
Expand description

Attempts to remove a file at the specified path, retrying up to 4 times on failure.

This function tries to delete the file located at the given path. If the removal fails (e.g., due to temporary filesystem locks or race conditions), it will retry up to four times before returning the final error.

§Parameters

  • path: The path to the file to be removed. Accepts any type implementing AsRef<Path>.

§Returns

  • An Result indicating success or failure. Returns Ok(()) if the file is removed, or an Err if all attempts fail.

§Examples

use regd_testing;

regd_testing::io::try_remove_file("temp.txt").expect("failed to remove file");