A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://doc.rust-lang.org/nightly/std/fs/fn.remove_dir_all.html below:

remove_dir_all in std::fs - Rust

Function remove_dir_all1.0.0 · Source
pub fn remove_dir_all<P: AsRef<Path>>(path: P) -> Result<()>
Expand description

Removes a directory at this path, after removing all its contents. Use carefully!

This function does not follow symbolic links and it will simply remove the symbolic link itself.

§Platform-specific behavior

These implementation details may change in the future.

§Time-of-check to time-of-use (TOCTOU) race conditions

See the module-level TOCTOU explanation.

On most platforms, fs::remove_dir_all protects against symlink TOCTOU races by default. However, on the following platforms, this protection is not provided and the function should not be used in security-sensitive contexts:

§Errors

See fs::remove_file and fs::remove_dir.

remove_dir_all will fail if remove_dir or remove_file fail on any constituent paths, including the root path. Consequently,

Consider ignoring the error if validating the removal is not required for your use case.

This function may return io::ErrorKind::DirectoryNotEmpty if the directory is concurrently written into, which typically indicates some contents were removed but not all. io::ErrorKind::NotFound is only returned if no removal occurs.

§Examples
use std::fs;

fn main() -> std::io::Result<()> {
    fs::remove_dir_all("/some/dir")?;
    Ok(())
}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4