4 releases (2 breaking)
0.3.0 | Feb 10, 2024 |
---|---|
0.2.0 | Mar 10, 2022 |
0.1.1 | Apr 9, 2020 |
0.1.0 | Apr 8, 2020 |
#1121 in Filesystem
60KB
785 lines
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(())
}
Dependencies
~7–14MB
~163K SLoC