2 stable releases
Uses new Rust 2024
| 1.1.0 | Oct 12, 2025 |
|---|---|
| 1.0.0 | Oct 12, 2025 |
#1154 in Filesystem
359 downloads per month
9KB
103 lines
Empty Inside Directory
Empty the contents of a directory without deleting the directory itself. This is a simple and lightweight library with minimal functions.
Usage
The parameter's signature is impl AsRef<Path>,
which means it can accept any type that implements AsRef<Path>,
such as &Path, PathBuf, String, &str, etc.
use empty_inside_dir::empty_dir;
use std::path::Path;
fn main() -> Result<(), std::io::Error> {
...
empty_dir("xxx")?;
Ok(())
}
Features
- Safe: Only operates on directories, returns error for files.
- Idempotent: Returns
Ok(())for non-existent paths. - Recursive: Removes all contents including subdirectories.
- Preserves Directory: The directory itself remains intact.
Open Source License
This crate is released under the Apache 2.0 License.