I'm not certain of your application. md5 checksum is generally used in situations where accuracy is favored over speed (or to present an additional barrier to foul play.)
In build systems where speed is king, file dating is generally used to evaluate directory equality. For example given the latest directory is: filesystem::path foo
and the directory in question is: filesystem::path bar
you could simply evaluate:
equal(filesystem::directory_iterator(foo), filesystem::directory_iterator(), filesystem::directory_iterator(bar), filesystem::directory_iterator(), [](const auto& lhs, const auto& rhs) { return filesystem::last_write_time(lhs) == filesystem::last_write_time(rhs); })
Live Example
A few notes about this one-liner:
- This is not a recursive function, it's evaluating only the dates immediately within
foo
and bar
- If you are working with directories, Visual Studio's implementation of
last_write_time
seems to have an issue with directories
- In a build system for example this has the tremendous advantage over an md5 checksum that I can change the
==
in the lambda to <
the one liner will still respond affirmatively if you have manually updated one of the files to a newer test version