list_files

Function list_files 

Source
pub fn list_files(folder_to_list: &str) -> i32
Expand description

Recursively list files in a directory and write their paths to a text file.

This function traverses the specified directory and its subdirectories, listing all the file paths found. It then writes these file paths to a text file named “file_list.txt” in the same directory where the function is called from.

The function also counts the number of files found and returns the count. Any encountered errors during the listing process are logged.

§Arguments

  • folder_to_list - The path to the directory to be recursively listed.

§Returns

The number of files listed.

§Examples

use file_integrity::list_files;

let folder_path = "/path/to/your/directory";
let nbs_of_file = list_files(folder_path);
println!("Number of Files: {}", nbs_of_file);

§Errors

This function logs any errors that occur during the listing and writing process.