[Bf-blender-cvs] [4b820fb] master: Fix T38311: cycles BVH cache crash on Windows.

Brecht Van Lommel noreply at git.blender.org
Thu Jan 23 01:15:48 CET 2014


Commit: 4b820fb673319989026433f284e11671885757c0
Author: Brecht Van Lommel
Date:   Thu Jan 23 01:13:09 2014 +0100
https://developer.blender.org/rB4b820fb673319989026433f284e11671885757c0

Fix T38311: cycles BVH cache crash on Windows.

===================================================================

M	intern/cycles/util/util_cache.cpp
M	intern/cycles/util/util_path.cpp
M	intern/cycles/util/util_path.h

===================================================================

diff --git a/intern/cycles/util/util_cache.cpp b/intern/cycles/util/util_cache.cpp
index f1c9dcd..e20c3a6 100644
--- a/intern/cycles/util/util_cache.cpp
+++ b/intern/cycles/util/util_cache.cpp
@@ -113,23 +113,7 @@ bool Cache::lookup(CacheData& key, CacheData& value)
 
 void Cache::clear_except(const string& name, const set<string>& except)
 {
-	string dir = path_user_get("cache");
-
-	if(boost::filesystem::exists(dir)) {
-		boost::filesystem::directory_iterator it(dir), it_end;
-
-		for(; it != it_end; it++) {
-#if (BOOST_FILESYSTEM_VERSION == 2)
-			string filename = it->path().filename();
-#else
-			string filename = it->path().filename().string();
-#endif
-
-			if(boost::starts_with(filename, name))
-				if(except.find(filename) == except.end())
-					boost::filesystem::remove(it->path());
-		}
-	}
+	path_cache_clear_except(name, except);
 }
 
 CCL_NAMESPACE_END
diff --git a/intern/cycles/util/util_path.cpp b/intern/cycles/util/util_path.cpp
index 1a0bf88..4fd5df4 100644
--- a/intern/cycles/util/util_path.cpp
+++ b/intern/cycles/util/util_path.cpp
@@ -264,5 +264,27 @@ FILE *path_fopen(const string& path, const string& mode)
 #endif
 }
 
+void path_cache_clear_except(const string& name, const set<string>& except)
+{
+	string dir = path_user_get("cache");
+
+	if(boost::filesystem::exists(dir)) {
+		boost::filesystem::directory_iterator it(dir), it_end;
+
+		for(; it != it_end; it++) {
+#if (BOOST_FILESYSTEM_VERSION == 2)
+			string filename = from_boost(it->path().filename());
+#else
+			string filename = from_boost(it->path().filename().string());
+#endif
+
+			if(boost::starts_with(filename, name))
+				if(except.find(filename) == except.end())
+					boost::filesystem::remove(to_boost(filename));
+		}
+	}
+
+}
+
 CCL_NAMESPACE_END
 
diff --git a/intern/cycles/util/util_path.h b/intern/cycles/util/util_path.h
index 3cffd7d..e9041e6 100644
--- a/intern/cycles/util/util_path.h
+++ b/intern/cycles/util/util_path.h
@@ -24,35 +24,45 @@
 
 #include <stdio.h>
 
+#include "util_set.h"
 #include "util_string.h"
 #include "util_types.h"
 #include "util_vector.h"
 
 CCL_NAMESPACE_BEGIN
 
+/* program paths */
 void path_init(const string& path = "", const string& user_path = "");
 string path_get(const string& sub = "");
 string path_user_get(const string& sub = "");
 
+/* path string manipulation */
 string path_filename(const string& path);
 string path_dirname(const string& path);
 string path_join(const string& dir, const string& file);
-
 string path_escape(const string& path);
+
+/* file info */
 bool path_exists(const string& path);
 string path_files_md5_hash(const string& dir);
+uint64_t path_modified_time(const string& path);
 
+/* directory utility */
 void path_create_directories(const string& path);
+
+/* file read/write utilities */
+FILE *path_fopen(const string& path, const string& mode);
+
 bool path_write_binary(const string& path, const vector<uint8_t>& binary);
 bool path_write_text(const string& path, string& text);
 bool path_read_binary(const string& path, vector<uint8_t>& binary);
 bool path_read_text(const string& path, string& text);
 
-uint64_t path_modified_time(const string& path);
-
+/* source code utility */
 string path_source_replace_includes(const string& source, const string& path);
 
-FILE *path_fopen(const string& path, const string& mode);
+/* cache utility */
+void path_cache_clear_except(const string& name, const set<string>& except);
 
 CCL_NAMESPACE_END




More information about the Bf-blender-cvs mailing list