Reliable and fast directory removal functions.
-
remove_dir_all
- on non-Windows this is a re-export ofstd::fs::remove_dir_all
. For Windows an implementation that handles the locking of directories that occurs when deleting directory trees rapidly. -
remove_dir_contents
- as forremove_dir_all
but does not delete the supplied root directory. -
ensure_empty_dir
- as forremove_dir_contents
but will create the directory if it does not exist.
extern crate remove_dir_all;
use remove_dir_all::*;
fn main() {
remove_dir_all("./temp/").unwrap();
remove_dir_contents("./cache/").unwrap();
}
The minimum rust version for remove_dir_all
is the latest stable release, and the minimum version may be bumped through patch releases. You can pin to a specific version by setting by add =
to your version (e.g. =0.6.0
), or commiting a Cargo.lock
file to your project.