[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40631] branches/cycles/intern/cycles/util : Cycles: fix error in md5 hash computation for files in directories below

Brecht Van Lommel brechtvanlommel at pandora.be
Tue Sep 27 21:35:42 CEST 2011


Revision: 40631
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40631
Author:   blendix
Date:     2011-09-27 19:35:41 +0000 (Tue, 27 Sep 2011)
Log Message:
-----------
Cycles: fix error in md5 hash computation for files in directories below
the first level.

Modified Paths:
--------------
    branches/cycles/intern/cycles/util/util_md5.cpp
    branches/cycles/intern/cycles/util/util_path.cpp

Modified: branches/cycles/intern/cycles/util/util_md5.cpp
===================================================================
--- branches/cycles/intern/cycles/util/util_md5.cpp	2011-09-27 19:04:27 UTC (rev 40630)
+++ branches/cycles/intern/cycles/util/util_md5.cpp	2011-09-27 19:35:41 UTC (rev 40631)
@@ -313,8 +313,10 @@
 {
 	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];

Modified: branches/cycles/intern/cycles/util/util_path.cpp
===================================================================
--- branches/cycles/intern/cycles/util/util_path.cpp	2011-09-27 19:04:27 UTC (rev 40630)
+++ branches/cycles/intern/cycles/util/util_path.cpp	2011-09-27 19:35:41 UTC (rev 40631)
@@ -85,17 +85,14 @@
 	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,7 +102,15 @@
 			}
 		}
 	}
+}
 
+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();
 }
 




More information about the Bf-blender-cvs mailing list