| 78 | } |
| 79 | |
| 80 | std::size_t ReadersCache::getFileSize(std::size_t index) |
| 81 | { |
| 82 | const auto indexIt = mIndex.find(index); |
| 83 | if (indexIt == mIndex.end()) |
| 84 | return 0; |
| 85 | switch (indexIt->second->mState) |
| 86 | { |
| 87 | case State::Busy: |
| 88 | case State::Free: |
| 89 | if (!indexIt->second->mReader.getName().empty()) |
| 90 | return indexIt->second->mReader.getFileSize(); |
| 91 | throw std::logic_error("ESMReader at index " + std::to_string(index) + " has not been opened yet"); |
| 92 | case State::Closed: |
| 93 | if (indexIt->second->mFileSize) |
| 94 | return *indexIt->second->mFileSize; |
| 95 | throw std::logic_error("ESMReader at index " + std::to_string(index) + " has forgotten its file size"); |
| 96 | default: |
| 97 | throw std::logic_error("ESMReader at index " + std::to_string(index) + " in unknown state"); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | void ReadersCache::closeExtraReaders() |
| 102 | { |
no test coverage detected