| 90 | } |
| 91 | |
| 92 | int FileCache::Load(const char* name) |
| 93 | { |
| 94 | // search the cache |
| 95 | int index = Find(name); |
| 96 | if (index >= 0) |
| 97 | { |
| 98 | if (index != 0) |
| 99 | { |
| 100 | MoveToFront(index); |
| 101 | } |
| 102 | return 0; |
| 103 | } |
| 104 | // not cached yet |
| 105 | FileInCache* newEntry = new FileInCache(name); |
| 106 | if (newEntry->_data.fail()) |
| 107 | { |
| 108 | delete newEntry; |
| 109 | // RptF is a no-op in release builds — surface the missing file through the |
| 110 | // normal log so callers can see WHICH file the subsequent Cache failure is for. |
| 111 | LOG_WARN(Core, "FileCache: file '{}' not found", name); |
| 112 | return -1; |
| 113 | } |
| 114 | _cache.Insert(0, newEntry); |
| 115 | PoseidonAssert(newEntry->_data.tellg() == 0); |
| 116 | // maintain size statistics |
| 117 | _size += newEntry->_data.rest(); |
| 118 | Maintain(); |
| 119 | return 0; |
| 120 | } |
| 121 | |
| 122 | bool FileCache::IsLoaded(const char* name) |
| 123 | { |