| 20 | } |
| 21 | |
| 22 | bool SharedCacheBuilder::AddFile( |
| 23 | const std::string& filePath, const std::string& fileName, const CacheEntryType cacheType) |
| 24 | { |
| 25 | // Skip already processed files. |
| 26 | if (auto [_, inserted] = m_processedFiles.insert(filePath); !inserted) |
| 27 | return false; |
| 28 | // We only want to process files containing the base file name. |
| 29 | if (fileName.find(m_primaryFileName) == std::string::npos) |
| 30 | return false; |
| 31 | // Skip map files, they contain some nice information... we don't use. |
| 32 | if (fileName.find(".map") != std::string::npos) |
| 33 | return false; |
| 34 | // Skip atlas files, they contain some nice information... we don't use. |
| 35 | if (fileName.find(".atlas") != std::string::npos) |
| 36 | return false; |
| 37 | // Skip bndb files! |
| 38 | if (fileName.find(".bndb") != std::string::npos) |
| 39 | return false; |
| 40 | |
| 41 | try |
| 42 | { |
| 43 | auto entry = CacheEntry::FromFile(filePath, fileName, cacheType); |
| 44 | m_cache.AddEntry(std::move(entry)); |
| 45 | } |
| 46 | catch (const std::exception& e) |
| 47 | { |
| 48 | // Just return false so the view init can continue. |
| 49 | m_logger->LogErrorF("Failed to add file '{}': {}", fileName, e.what()); |
| 50 | return false; |
| 51 | } |
| 52 | |
| 53 | return true; |
| 54 | } |
| 55 | |
| 56 | size_t SharedCacheBuilder::AddDirectory(const std::string& directoryPath) |
| 57 | { |