Crate copy_confirmer
source ·Expand description
Directory comparison library
Compares directories (source
and multiple dirs in destinations
) by creating hash of each
file in source
and then checking that there is at least one file with the same hash in one of
directories in destinations
. If all files in source
are in at least one of the destination
directories, we return ConfirmerResult::Ok
, otherwise we list all the missing files in
ConfirmerResult::MissingFiles
.
Example usage
Suppose we have a directory structure:
tests/fixtures/
├── dir_A
│ ├── bar.txt
│ └── foo.txt
└── dir_B
└── foo.txt
We can use copy confirmer to confirm that dir_B
is a copy of dir_A
:
use copy_confirmer::*;
let cc = CopyConfirmer::new(1);
let missing_files = cc.compare("tests/fixtures/dir_A",
&["tests/fixtures/dir_B"])?;
let expected_missing = vec!["tests/fixtures/dir_A/bar.txt".into()];
assert_eq!(missing_files, ConfirmerResult::MissingFiles(expected_missing));
Structs
- An error produced when comparing directories
- Structure providing methods for directory comparison
- Holds information on all paths in source and destinations that contain the same file
Enums
- Indicates whether there are files missing in destination dirs