Function remove_dir_all::remove_dir_all
source · pub fn remove_dir_all<P: AsRef<Path>>(path: P) -> Result<()>
Expand description
Reliably removes a directory and all of its children.
use std::fs;
use remove_dir_all::*;
fs::create_dir("./temp/").unwrap();
remove_dir_all("./temp/").unwrap();
Note: calling this on a non-directory (e.g. a symlink to a directory) will error.
RemoveDir::remove_dir_contents
is somewhat safer and
recommended as the path based version is subject to file system races
determining what to delete: a privileged process could be attacked by
replacing parent directories of the supplied path with a link (e.g. to
/etc). Consider using RemoveDir::remove_dir_contents
instead.