| 115 | } // namespace |
| 116 | |
| 117 | File::File(const wchar_t *filepath) |
| 118 | { |
| 119 | fp_ = nullptr; |
| 120 | hFile_ = CreateFile(filepath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN | FILE_FLAG_WRITE_THROUGH, nullptr); |
| 121 | if (hFile_ == INVALID_HANDLE_VALUE) |
| 122 | { |
| 123 | PrintErrorMessage("Open file error!"); |
| 124 | size_ = 0; |
| 125 | return; |
| 126 | } |
| 127 | size_ = GetFileSize(hFile_, nullptr); |
| 128 | hMap_ = CreateFileMapping(hFile_, nullptr, PAGE_READWRITE, 0, 0, nullptr); |
| 129 | if (hMap_ == INVALID_HANDLE_VALUE) |
| 130 | { |
| 131 | PrintErrorMessage("Map file error!"); |
| 132 | return; |
| 133 | } |
| 134 | fp_ = MapViewOfFile(hMap_, FILE_MAP_ALL_ACCESS, 0, 0, 0); |
| 135 | } |
| 136 | |
| 137 | void File::UnMapFile(size_t new_size) |
| 138 | { |
nothing calls this directly
no test coverage detected