From 9a193b06eb0e5ca463576e4fa9e8da0a70022a4a Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 20 Jul 2009 17:57:56 -0700 Subject: Make sure that non-existent files still affect hashing The fact that a file _doesn't_ exist is significant, so adding such a file to a computed hash should still influence the output. * hash.cxx (hash::add_file): add bogus stat info for non-existent files --- hash.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hash.cxx b/hash.cxx index e550be76..a0608c03 100644 --- a/hash.cxx +++ b/hash.cxx @@ -52,12 +52,12 @@ hash::add_file(const std::string& filename) { struct stat st; - if (stat(filename.c_str(), &st) == 0) - { - add(filename); - add(st.st_size); - add(st.st_mtime); - } + if (stat(filename.c_str(), &st) != 0) + st.st_size = st.st_mtime = -1; + + add(filename); + add(st.st_size); + add(st.st_mtime); } -- cgit