Skip to content

Commit 1b1a231

Browse files
authored
Make FileBufferNodeWin aware of UWP Win32 API (#319)
1 parent b21daa7 commit 1b1a231

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

trantor/net/inner/FileBufferNodeWin.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#include <trantor/net/inner/BufferNode.h>
22
#include <windows.h>
3+
#include <fileapi.h>
4+
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
5+
#define UWP 1
6+
#else
7+
#define UWP 0
8+
#endif
39

410
namespace trantor
511
{
@@ -9,13 +15,19 @@ class FileBufferNode : public BufferNode
915
public:
1016
FileBufferNode(const wchar_t *fileName, long long offset, long long length)
1117
{
18+
#if UWP
19+
sendHandle_ = CreateFile2(
20+
fileName, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr);
21+
22+
#else
1223
sendHandle_ = CreateFileW(fileName,
1324
GENERIC_READ,
1425
FILE_SHARE_READ,
1526
nullptr,
1627
OPEN_EXISTING,
1728
FILE_ATTRIBUTE_NORMAL,
1829
nullptr);
30+
#endif
1931
if (sendHandle_ == INVALID_HANDLE_VALUE)
2032
{
2133
LOG_SYSERR << fileName << " open error";

0 commit comments

Comments
 (0)