empty_inside_dir

Crates.ioempty_inside_dir
lib.rsempty_inside_dir
version1.1.0
created_at2025-10-12 07:53:06.83961+00
updated_at2025-10-12 08:56:39.835823+00
descriptionEmpty the contents of a directory without deleting itself.
homepage
repositoryhttps://github.com/aprosail/empty_inside_dir
max_upload_size
id1879028
size23,606
James Aprosail (aprosail)

documentation

README

Empty Inside Directory

en(English) | zh(中文)

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.

Commit count: 0

cargo fmt