mirror of
https://github.com/yhirose/cpp-httplib
synced 2024-11-21 14:29:10 -07:00
Fix build on Windows with no WINAPI_PARTITION_APP support (#1865)
This commit is contained in:
parent
bdefdce1ae
commit
388a8c007c
1 changed files with 10 additions and 0 deletions
10
httplib.h
10
httplib.h
|
@ -2832,15 +2832,25 @@ inline bool mmap::open(const char *path) {
|
||||||
if (!::GetFileSizeEx(hFile_, &size)) { return false; }
|
if (!::GetFileSizeEx(hFile_, &size)) { return false; }
|
||||||
size_ = static_cast<size_t>(size.QuadPart);
|
size_ = static_cast<size_t>(size.QuadPart);
|
||||||
|
|
||||||
|
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
|
||||||
hMapping_ =
|
hMapping_ =
|
||||||
::CreateFileMappingFromApp(hFile_, NULL, PAGE_READONLY, size_, NULL);
|
::CreateFileMappingFromApp(hFile_, NULL, PAGE_READONLY, size_, NULL);
|
||||||
|
#else
|
||||||
|
hMapping_ =
|
||||||
|
::CreateFileMappingW(hFile_, NULL, PAGE_READONLY, size.HighPart,
|
||||||
|
size.LowPart, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (hMapping_ == NULL) {
|
if (hMapping_ == NULL) {
|
||||||
close();
|
close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
|
||||||
addr_ = ::MapViewOfFileFromApp(hMapping_, FILE_MAP_READ, 0, 0);
|
addr_ = ::MapViewOfFileFromApp(hMapping_, FILE_MAP_READ, 0, 0);
|
||||||
|
#else
|
||||||
|
addr_ = ::MapViewOfFile(hMapping_, FILE_MAP_READ, 0, 0, 0);
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
fd_ = ::open(path, O_RDONLY);
|
fd_ = ::open(path, O_RDONLY);
|
||||||
if (fd_ == -1) { return false; }
|
if (fd_ == -1) { return false; }
|
||||||
|
|
Loading…
Reference in a new issue