Expand description

Simple functions to help with file naming and file iteration Ported from the filetools library written by Jonathan Grizou

Examples

use filetools::filehelpers;
use std::path::PathBuf;
 
fn main() -> Result <(), Box<dyn std::error::Error>> {
    /// 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

Functions that help in iterating files and folders

Functions that generate PathBuf filenames