11#if defined(_WIN32) && !defined(_WINDOWS_) && !defined(WINAPI)
51 std::error_code
error;
53 error.assign(GetLastError(), std::system_category());
89 return n & 0xffffffff;
93 template <
typename VALUE_TYPE>
94 inline void mmap_sink<VALUE_TYPE>::sync(std::error_code&
error)
noexcept
99 error = std::make_error_code(std::errc::bad_file_descriptor);
124 template <
typename VALUE_TYPE>
125 inline file_handle_type mmap_sink<VALUE_TYPE>::open_file(
const std::filesystem::path& path, std::error_code&
error)
noexcept
129 error = std::make_error_code(std::errc::invalid_argument);
130 return invalid_handle;
134 const auto handle =
CreateFileW(path.c_str(), (0x80000000L) | (0x40000000L), 0x00000001 | 0x00000002, 0, 3, 0x00000080, 0);
138 if (handle == invalid_handle)
144 template <
typename VALUE_TYPE>
145 typename mmap_sink<VALUE_TYPE>::mmap_context mmap_sink<VALUE_TYPE>::memory_map(
const file_handle_type file_handle,
const int64_t offset,
const int64_t length, std::error_code&
error)
noexcept
152 if (file_mapping_handle == invalid_handle)
177 ctx.file_mapping_handle = file_mapping_handle;
181 template <
typename VALUE_TYPE>
182 void basic_mmap_base<VALUE_TYPE>::unmap()
noexcept
184 if (!this->is_open()) {
return; }
187 if (this->is_mapped())
193 if (data_) {
::munmap(
const_cast<pointer
>(get_mapping_start()), mapped_length_); }
203 this->data_ =
nullptr;
204 this->length_ = this->mapped_length_ = 0;
205 this->file_handle_ = invalid_handle;
206 this->file_mapping_handle_ = invalid_handle;
209 template <
typename VALUE_TYPE>
210 file_handle_type mmap_source<VALUE_TYPE>::open_file(
const std::filesystem::path& path, std::error_code&
error)
noexcept
215 error = std::make_error_code(std::errc::invalid_argument);
216 return invalid_handle;
219 const auto handle =
CreateFileW(path.c_str(), (0x80000000L), 0x00000001 | 0x00000002, 0, 3, 0x00000080, 0);
223 if (handle == invalid_handle)
230 template <
typename VALUE_TYPE>
231 typename mmap_source<VALUE_TYPE>::mmap_context mmap_source<VALUE_TYPE>::memory_map(
const file_handle_type file_handle,
const int64_t offset,
const int64_t length, std::error_code&
error)
noexcept
238 if (file_mapping_handle == invalid_handle)
264 ctx.file_mapping_handle = file_mapping_handle;
constexpr auto bit_count
Equal to the number of bits in the type.
Primary namespace for everything in this library.