dir-cmp
This Rust library aims to provide convient functions to compare to two file trees.
Library
Usage
//define options
let diff_options = Options ;
//get dirs to compare
let left_dir = new;
let right_dir = new;
//compare
let result = compare_dirs;
Filter
In order blacklist(exclude) or whitelist (include) any folder or file names, a filter can be added to the compare options.
A filter consists of a list of regular expressions.
// define filter to ignore ".git" directory
let regex = new.unwrap;
let filter = Exclude;
//define options
let diff_options = Options ;
//get dirs to compare
let left_dir = new;
let right_dir = new;
//compare
let result = compare_dirs;
Full vs Light
The compare_dirs function is implemented in two flavors: full and light.
The difference is that full::compare_dirs compares also file contents while light::compare_dirs only compares names / pathes.
Cli
The lib can be tested using the Cli provided in this repo. It was inspired by diff, but only covers the basic functionality.
Usage
Performance
To evaluate the speed of this library, we can compare it against diff.
One simple approach is to simply compare this repo against itself:
time diff -r . .
// 0.01s user 0.19s system 99% cpu 0.209 total
time dir-cmp -r . .
// 0.26s user 0.46s system 75% cpu 0.945 total
The result clearly shows that there is a lot of room for improvement.