filetools

Crates.iofiletools
lib.rsfiletools
version0.3.0
sourcesrc
created_at2020-04-08 13:03:54.529999
updated_at2024-02-10 20:36:44.275007
descriptionHelper functions for path operations
homepage
repositoryhttps://github.com/Tyrannican/filetools-rs
max_upload_size
id227615
size83,968
Graham Keenan (Tyrannican)

documentation

README

Filetools

Simple crate for perfoming some small Path operations in Rust.

Offers the user the ability to:

  • Create directories (single / multiple at a time)
  • Check given filepaths match a pattern
  • List all files / directories in a path
    • This can be just the files / directories inside the path root
    • This can also include files / directories in ALL subdirectories contained in the path
  • List files / directories as above but filter the results based on a Filter Pattern
  • Some general naming functions for creating PathBuf names

More will be added in the future but this should suffice for small path operations.

Usage

Add to your Cargo.toml

[dependencies]
filetools = "0.3.0"

Then import into your project:

use filetools::{FtFilter, list_nested_files_with_filter};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Get all Lua files in the Neovim directory
    let root_path = "/home/user/.config/nvim";
    let filter = FtFilter::Raw("lua".to_string());
    let lua_files = list_nested_files_with_filter(&root_path, filter).await?;

    // Delete them all, we hate Lua
    for lua_file in lua_files.into_iter() {
        tokio::fs::remove_file(lua_file).await?;
    }

    Ok(())
}
Commit count: 12

cargo fmt