diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2014-01-23 04:13:09 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2014-01-23 04:13:46 +0400 |
commit | 4b820fb673319989026433f284e11671885757c0 (patch) | |
tree | d011584f809d01ca5fb90b7e50ad4f64b15c2dad | |
parent | 282ad434a8bca760372f98ceec8a15725bf30bd1 (diff) |
Fix T38311: cycles BVH cache crash on Windows.
-rw-r--r-- | intern/cycles/util/util_cache.cpp | 18 | ||||
-rw-r--r-- | intern/cycles/util/util_path.cpp | 22 | ||||
-rw-r--r-- | intern/cycles/util/util_path.h | 18 |
3 files changed, 37 insertions, 21 deletions
diff --git a/intern/cycles/util/util_cache.cpp b/intern/cycles/util/util_cache.cpp index f1c9dcd79ab..e20c3a67b75 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 1a0bf88bbd1..4fd5df4316d 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 3cffd7d91e9..e9041e63dae 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 |