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.txtWe 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));We can show a progress bar by setting with_progress_bar. We can exclude files from comparison with add_excluded_pattern.
Structs§
- Confirmer
Error - An error produced when comparing directories
- Copy
Confirmer - Structure providing methods for directory comparison
- File
Found - Holds information on all paths in source and destinations that contain the same file
Enums§
- Confirmer
Result - Indicates whether there are files missing in destination dirs
- Exclude
Pattern - Exclude pattern