int main(int argc, char *argv[]) { if (argc < 2) { printf("Usage: %s file [file [file [...]]]\n", argv[0]); exit(1); } while (0<--argc) { uint_32 crc = file_crc32(*++argv); printf("%.8X %s\n", crc, *argv); } return 0; }
// find out if the file is duplicated and store the data as needed. void check_equals(work_package_t &work_package, const fs::path& path) { auto crc32 = file_crc32(work_package.file_cmp_options, path); auto range = work_package.crc32_to_path.equal_range(crc32); bool need_to_add = true; for (auto it = range.first; it != range.second; ++it) { auto cmp_path = it->second; if (file_compare(work_package.file_cmp_options, cmp_path, path)) { need_to_add = false; auto equal_it = work_package.equals.find(cmp_path); if (equal_it == work_package.equals.end()) { work_package.equals[cmp_path].push_back(cmp_path); } work_package.equals[cmp_path].push_back(path); } } if (need_to_add) { work_package.crc32_to_path.insert(std::make_pair(crc32, path)); } }