Fix build on Windows with no WINAPI_PARTITION_APP support (#1865)
Some checks failed
test / ubuntu (push) Has been cancelled
test / macos (push) Has been cancelled
test / windows (push) Has been cancelled

This commit is contained in:
Daniel Ludwig 2024-06-24 21:13:37 +02:00 committed by GitHub
parent bdefdce1ae
commit 388a8c007c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2832,15 +2832,25 @@ inline bool mmap::open(const char *path) {
if (!::GetFileSizeEx(hFile_, &size)) { return false; }
size_ = static_cast<size_t>(size.QuadPart);
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
hMapping_ =
::CreateFileMappingFromApp(hFile_, NULL, PAGE_READONLY, size_, NULL);
#else
hMapping_ =
::CreateFileMappingW(hFile_, NULL, PAGE_READONLY, size.HighPart,
size.LowPart, NULL);
#endif
if (hMapping_ == NULL) {
close();
return false;
}
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
addr_ = ::MapViewOfFileFromApp(hMapping_, FILE_MAP_READ, 0, 0);
#else
addr_ = ::MapViewOfFile(hMapping_, FILE_MAP_READ, 0, 0, 0);
#endif
#else
fd_ = ::open(path, O_RDONLY);
if (fd_ == -1) { return false; }