From 388a8c007c96857b36901f3801f6572362ad6b17 Mon Sep 17 00:00:00 2001 From: Daniel Ludwig Date: Mon, 24 Jun 2024 21:13:37 +0200 Subject: [PATCH] Fix build on Windows with no WINAPI_PARTITION_APP support (#1865) --- httplib.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/httplib.h b/httplib.h index 0085a39..616b914 100644 --- a/httplib.h +++ b/httplib.h @@ -2832,15 +2832,25 @@ inline bool mmap::open(const char *path) { if (!::GetFileSizeEx(hFile_, &size)) { return false; } size_ = static_cast(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; }