| 167 | } |
| 168 | |
| 169 | void FileCache::Store(QIFStreamB& stream, const char* name) |
| 170 | { |
| 171 | // search the cache |
| 172 | int index = Find(name); |
| 173 | if (index >= 0) |
| 174 | { |
| 175 | if (index != 0) |
| 176 | { |
| 177 | MoveToFront(index); |
| 178 | } |
| 179 | return; |
| 180 | } |
| 181 | // not cached yet |
| 182 | FileInCache* newEntry = new FileInCache(stream, name); |
| 183 | _cache.Insert(0, newEntry); |
| 184 | PoseidonAssert(newEntry->_data.tellg() == 0); |
| 185 | _size += newEntry->_data.rest(); |
| 186 | Maintain(); |
| 187 | } |
| 188 | void FileCache::Maintain() |
| 189 | { |
| 190 | while ((_size > _maxSize || _cache.Size() > _maxFiles) && _cache.Size() > 1) |