Function scan_directory

Source
pub async fn scan_directory(
    dir_path: &str,
    auto_convert: bool,
    verbose: bool,
) -> Result<()>
Expand description

Scans a directory for non-UTF-8 encoded files and optionally converts them to UTF-8

§Arguments

  • dir_path - The directory path to scan
  • auto_convert - Whether to automatically convert files to UTF-8
  • verbose - Whether to show detailed encoding information

§Returns

Returns Ok(()) if the operation was successful, or an error if something went wrong

§Example

use file_kitty::encoding::scan_directory;
 
#[tokio::main]
async fn main() -> anyhow::Result<()> {
    scan_directory("./my_project", false, false).await?;
    Ok(())
}
Examples found in repository?
examples/encoding/main.rs (line 13)
6async fn main() -> Result<()> {
7    // Get the path of the example file directory
8    let example_dir = Path::new(env!("CARGO_MANIFEST_DIR"))
9        .join("examples")
10        .join("encoding");
11    
12    println!("Start to scan directory: {}", example_dir.display());
13    scan_directory(example_dir.to_str().unwrap(), false, false).await?;
14    
15    Ok(())
16}