Skip to content

Commit

Permalink
Fix build on Windows with no WINAPI_PARTITION_APP support (#1865)
Browse files Browse the repository at this point in the history
  • Loading branch information
code-disaster committed Jun 24, 2024
1 parent bdefdce commit 388a8c0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions httplib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down

0 comments on commit 388a8c0

Please sign in to comment.