Expand description
Crate to help with simple file / folder operations.
Provides helper functions to:
- Create directories
- Check filepaths contain a pattern
- List files / directories both iteratively and recursively
- List files / directories both iteratively and recursively with filters
- Generate names for files / directories
§Async vs Sync
The operations in this crate are designed for async/await, however sync variations
of the operations exist in the crate::sync
module.
§Example
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(())
}
Modules§
- Functions that generate PathBuf filenames
- Sync variations of the main
crate
functions
Enums§
- Filter types for listing files / directories
Functions§
- Creates multiple directories inside the target path.
- Creates a range of numeric folders in the given path
- Creates a directory at the given path.
- Checks if a given pattern is considered a subdirectory of the given path
- Lists all directories in the given directory (not including subdirectories).
- Lists directories in a given directory (not including subdirectories) matching a filter pattern.
- Lists all files in the given directory (not including subdirectories).
- Lists files in a folder (not including subdirectories) matching a filter pattern.
- Lists all directories in a directory including ALL subdirectories
- Lists directories in a given directory (including ALL subdirectories) matching a filter pattern.
- Lists all files in a directory including ALL subdirectories
- Lists files in a folder (including ALL subdirectories) matching a filter pattern.
- Determines if a path contains a given pattern