[−][src]Crate filetools
Simple functions to help with file naming and file iteration Ported from the filetools library written by Jonathan Grizou
Examples
use filetools::filehelpers::FileHelpers; use std::io::Result; use std::path::PathBuf; fn main() -> Result <()> { /// Creating a directory let new_path = PathBuf::from("./test"); let _ = FileHelpers::ensure_dir(new_path)?; /// Iterating through all files in a directory let nr_search = PathBuf::from("./test"); let r_search = PathBuf::from("./test"); // Non-recursive search of directroy, just files in search folder let non_recursed_files = FileHelpers::list_files(nr_search, false); // Recursive search of directory, gets all files in directory and all sub-directories let recursed_files = FileHelpers::list_files(r_search, true); /// Iterating through all folders in a directory let nr_search = PathBuf::from("./test"); let r_search = PathBuf::from("./test"); // Non-recursive search for all folders, just folders in search directory let non_recursive_folders = FileHelpers::list_folders(nr_search, false); // Recursive search of all folders, all subfolders in a directory as well let recursive_folders = FileHelpers::list_folders(r_search, true); Ok(()) }
Modules
filehelpers | Functions that help in iterating files and folders |
filenaming | Functions that generate PathBuf filenames |