| 216 | }; |
| 217 | |
| 218 | bool SceneCache::hasValidCache(const Key& key) |
| 219 | { |
| 220 | auto cachePath = getCachePath(key); |
| 221 | if (!std::filesystem::exists(cachePath)) return false; |
| 222 | |
| 223 | // Open file. |
| 224 | std::ifstream fs(cachePath.c_str(), std::ios_base::binary); |
| 225 | if (fs.bad()) return false; |
| 226 | |
| 227 | // Verify header. |
| 228 | Header header; |
| 229 | fs.read(reinterpret_cast<char*>(&header), sizeof(header)); |
| 230 | return !fs.eof() && header.isValid(); |
| 231 | } |
| 232 | |
| 233 | void SceneCache::writeCache(const Scene::SceneData& sceneData, const Key& key) |
| 234 | { |