build_helper::fs

Function recursive_remove

Source
pub fn recursive_remove<P: AsRef<Path>>(path: P) -> Result<()>
Expand description

A wrapper around std::fs::remove_dir_all that can also be used on non-directory entries, including files and symbolic links.

  • This will produce an error if the target path is not found.
  • Like std::fs::remove_dir_all, this helper does not traverse symbolic links, will remove symbolic link itself.
  • This helper is not robust against races on the underlying filesystem, behavior is unspecified if this helper is called concurrently.
  • This helper is not robust against TOCTOU problems.

FIXME: this implementation is insufficiently robust to replace bootstrap’s clean rm_rf implementation:

  • This implementation currently does not perform retries.