diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-09-27 23:35:41 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-09-27 23:35:41 +0400 |
commit | f5b60afe4ec924f12ec859e4ca51cd8ed9eab3ad (patch) | |
tree | 915eb15ebf8f2408ad3f035dc2d1c7288208ed58 /intern/cycles/util | |
parent | d1ef6ac79b9bc6f17e61802bea3c3c2fbfcfcfd0 (diff) |
Cycles: fix error in md5 hash computation for files in directories below
the first level.
Diffstat (limited to 'intern/cycles/util')
-rw-r--r-- | intern/cycles/util/util_md5.cpp | 4 | ||||
-rw-r--r-- | intern/cycles/util/util_path.cpp | 15 |
2 files changed, 13 insertions, 6 deletions
diff --git a/intern/cycles/util/util_md5.cpp b/intern/cycles/util/util_md5.cpp index 90b8a1fe062..b871fad3636 100644 --- a/intern/cycles/util/util_md5.cpp +++ b/intern/cycles/util/util_md5.cpp @@ -313,8 +313,10 @@ bool MD5Hash::append_file(const string& filepath) { FILE *f = fopen(filepath.c_str(), "rb"); - if(!f) + if(!f) { + fprintf(stderr, "MD5: failed to open file %s\n", filepath.c_str()); return false; + } const size_t buffer_size = 1024; uint8_t buffer[buffer_size]; diff --git a/intern/cycles/util/util_path.cpp b/intern/cycles/util/util_path.cpp index d3f739e19f6..55e6a95b54a 100644 --- a/intern/cycles/util/util_path.cpp +++ b/intern/cycles/util/util_path.cpp @@ -85,17 +85,14 @@ bool path_exists(const string& path) return boost::filesystem::exists(path); } -string path_files_md5_hash(const string& dir) +static void path_files_md5_hash_recursive(MD5Hash& hash, const string& dir) { - /* computes md5 hash of all files in the directory */ - MD5Hash hash; - if(boost::filesystem::exists(dir)) { boost::filesystem::directory_iterator it(dir), it_end; for(; it != it_end; it++) { if(boost::filesystem::is_directory(it->status())) { - path_files_md5_hash(it->path().string()); + path_files_md5_hash_recursive(hash, it->path().string()); } else { string filepath = it->path().string(); @@ -105,6 +102,14 @@ string path_files_md5_hash(const string& dir) } } } +} + +string path_files_md5_hash(const string& dir) +{ + /* computes md5 hash of all files in the directory */ + MD5Hash hash; + + path_files_md5_hash_recursive(hash, dir); return hash.get_hex(); } |