| 98 | } |
| 99 | |
| 100 | Status MemmappedFileSystem::NewRandomAccessFile( |
| 101 | const string& filename, std::unique_ptr<RandomAccessFile>* result) { |
| 102 | if (!mapped_memory_) { |
| 103 | return errors::FailedPrecondition("MemmappedEnv is not initialized"); |
| 104 | } |
| 105 | const auto dir_element = directory_.find(filename); |
| 106 | if (dir_element == directory_.end()) { |
| 107 | return errors::NotFound("Region ", filename, " is not found"); |
| 108 | } |
| 109 | result->reset(new RandomAccessFileFromMemmapped( |
| 110 | GetMemoryWithOffset(dir_element->second.offset), |
| 111 | dir_element->second.length)); |
| 112 | return Status::OK(); |
| 113 | } |
| 114 | |
| 115 | Status MemmappedFileSystem::NewReadOnlyMemoryRegionFromFile( |
| 116 | const string& filename, std::unique_ptr<ReadOnlyMemoryRegion>* result) { |