Skip to main content

files_from_subdir

Function files_from_subdir 

Source
pub fn files_from_subdir(
    current_path: &Path,
    scan_subdirs: bool,
) -> Result<Vec<PathBuf>>
Expand description

Returns all files in a directory, optionally scanning subdirectories recursively.

§Arguments

  • current_path - The directory to scan
  • scan_subdirs - If true, recursively scans subdirectories; if false, only scans the top level

§Returns

Returns a vector of paths to all files found, or an error if the directory cannot be read.

§Examples

// Get only files in the current directory
let files = files_from_subdir(Path::new("./data"), false)?;

// Get all files recursively
let all_files = files_from_subdir(Path::new("./data"), true)?;