vcpkg/ports/trantor/001-uwp.patch
An Tao 9f803fd068
[drogon, trantor] Bump drogon to 1.9.2 and trantor to 1.5.16 (#36249)
* Bump drogon to 1.9.2 and trantor to 1.5.16

* Fix uwp compilation
2024-01-22 11:01:15 -08:00

37 lines
1.2 KiB
Diff

diff --git a/trantor/net/inner/FileBufferNodeWin.cc b/trantor/net/inner/FileBufferNodeWin.cc
index eb9fcbd..a0b9791 100644
--- a/trantor/net/inner/FileBufferNodeWin.cc
+++ b/trantor/net/inner/FileBufferNodeWin.cc
@@ -1,5 +1,11 @@
#include <trantor/net/inner/BufferNode.h>
#include <windows.h>
+#include <fileapi.h>
+#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
+#define UWP 1
+#else
+#define UWP 0
+#endif
namespace trantor
{
@@ -9,6 +15,11 @@ class FileBufferNode : public BufferNode
public:
FileBufferNode(const wchar_t *fileName, long long offset, long long length)
{
+#if UWP
+ sendHandle_ = CreateFile2(
+ fileName, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr);
+
+#else
sendHandle_ = CreateFileW(fileName,
GENERIC_READ,
FILE_SHARE_READ,
@@ -16,6 +27,7 @@ class FileBufferNode : public BufferNode
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
nullptr);
+#endif
if (sendHandle_ == INVALID_HANDLE_VALUE)
{
LOG_SYSERR << fileName << " open error";