#diff #directory #changed #compare #list #folder #recursion

folder_compare

Compare two folders and get a list of changed and new files

6 releases (3 breaking)

0.4.0 Sep 17, 2020
0.3.0 May 30, 2020
0.2.0 May 22, 2020
0.1.2 May 20, 2020

#350 in Parser tooling

Download history 12/week @ 2024-10-27 17/week @ 2024-11-03 33/week @ 2024-11-10 83/week @ 2024-11-17 22/week @ 2024-11-24 34/week @ 2024-12-01 209/week @ 2024-12-08 201/week @ 2024-12-15 31/week @ 2024-12-22 128/week @ 2024-12-29 150/week @ 2025-01-05 86/week @ 2025-01-12 81/week @ 2025-01-19 122/week @ 2025-01-26 136/week @ 2025-02-02 70/week @ 2025-02-09

409 downloads per month
Used in 2 crates

Apache-2.0

7KB
81 lines

folder_compare

A library to recursively compare files in two folders and return two lists of files: One with exclusive Files for the first folder one list with changed files between folders.

folder_compare also takes a list of Strings acting as exclude patterns using RegexSet.

Overall the functionality is comparable to a diff -rq folder1 folder2 -X excludepatterns.pat on unix like systems

For recognizing changed files, hashing with FxHasher is used.

Licensed under Apache-2.0

Usage

Add folder_compare as a dependency to your project's Cargo.toml:

[dependencies]
folder_compare = "0.3"

Example

The following code recursively iterates over two directories and returns lists of changed and new files excluding those with ".doc" and ".txt" as part of the name/path.

use std::path::Path;
use folder_compare;

let excluded = vec![".doc".to_string(), ".txt".to_string()];
let result = FolderCompare::new(Path::new("/tmp/a"), Path::new("/tmp/b"), &excluded).unwrap();

let changed_files = result.changed_files;
let new_filed = result.new_files;

Dependencies

~2–10MB
~90K SLoC