| 127 | class TMemoryMap::TImpl: public TAtomicRefCount<TImpl> { |
| 128 | public: |
| 129 | inline void CreateMapping() { |
| 130 | #if defined(_win_) |
| 131 | Mapping_ = nullptr; |
| 132 | if (Length_) { |
| 133 | Mapping_ = CreateFileMapping(File_.GetHandle(), nullptr, |
| 134 | (Mode_ & oAccessMask) == TFileMap::oRdWr ? PAGE_READWRITE : PAGE_READONLY, |
| 135 | (DWORD)(Length_ >> 32), (DWORD)(Length_ & 0xFFFFFFFF), nullptr); |
| 136 | if (Mapping_ == nullptr) { |
| 137 | ythrow yexception() << "Can't create file mapping of '" << DbgName_ << "': " << LastSystemErrorText(); |
| 138 | } |
| 139 | } else { |
| 140 | Mapping_ = MAP_FAILED; |
| 141 | } |
| 142 | #elif defined(_unix_) |
| 143 | if (!(Mode_ & oNotGreedy)) { |
| 144 | PtrStart_ = mmap((caddr_t) nullptr, Length_, ModeToMmapProt(Mode_), ModeToMmapFlags(Mode_), File_.GetHandle(), 0); |
| 145 | |
| 146 | if ((MAP_FAILED == PtrStart_) && Length_) { |
| 147 | ythrow yexception() << "Can't map " << (unsigned long)Length_ << " bytes of file '" << DbgName_ << "' at offset 0: " << LastSystemErrorText(); |
| 148 | } |
| 149 | } else { |
| 150 | PtrStart_ = nullptr; |
| 151 | } |
| 152 | #endif |
| 153 | } |
| 154 | |
| 155 | void CheckFile() const { |
| 156 | if (!File_.IsOpen()) { |
nothing calls this directly
no test coverage detected