| 111 | } |
| 112 | |
| 113 | Result<Void> Bundle::lockFreeLoadEntriesIfNeeded() { |
| 114 | if (_loadedEntries) { |
| 115 | return Void(); |
| 116 | } |
| 117 | |
| 118 | if (_decompressedBundle == nullptr) { |
| 119 | return Valdi::Error(STRING_FORMAT("Bundle '{}' was not loaded", _name)); |
| 120 | } |
| 121 | |
| 122 | _loadedEntries = true; |
| 123 | |
| 124 | for (const auto& entryPath : _decompressedBundle->getAllEntryPaths()) { |
| 125 | if (_entryByPath.find(entryPath) == _entryByPath.end()) { |
| 126 | auto entry = _decompressedBundle->getEntry(entryPath); |
| 127 | _entryByPath[entryPath] = BytesView(_decompressedBundle, entry->data, entry->size); |
| 128 | _allEntryPaths.emplace_back(entryPath); |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | return Void(); |
| 133 | } |
| 134 | |
| 135 | Result<BytesView> Bundle::getEntry(const StringBox& path) { |
| 136 | std::lock_guard<std::recursive_mutex> guard(_mutex); |