From cc788185bdf40e04326e83f0119507ccb09df2b2 Mon Sep 17 00:00:00 2001 From: Tymi Date: Wed, 7 Jan 2026 21:38:20 +0100 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Change=20GetFileSize?= =?UTF-8?q?=20to=20GetFileSizeEx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Improve accuracy, compatibility and readability by using the modern GetFileSizeEx API in IOCP implementation of the I/O Engine. --- src/io_engine_iocp.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/io_engine_iocp.cpp b/src/io_engine_iocp.cpp index 41778c4..9efa6d9 100644 --- a/src/io_engine_iocp.cpp +++ b/src/io_engine_iocp.cpp @@ -709,11 +709,10 @@ namespace asyncpp::io::detail { void io_engine_iocp::file_close(file_handle_t fd) { ::CloseHandle(fd); } uint64_t io_engine_iocp::file_size(file_handle_t fd) { - DWORD high; - auto res = GetFileSize(fd, &high); - if (res == INVALID_FILE_SIZE && GetLastError() != NO_ERROR) + LARGE_INTEGER file_size{}; + if (GetFileSizeEx(fd, &size) == FALSE) throw std::system_error(GetLastError(), std::system_category()); - return (static_cast(high) << 32) + res; + return file_size.QuadPart; } bool io_engine_iocp::enqueue_readv(file_handle_t fd, void* buf, size_t len, uint64_t offset, completion_data* cd) { From 0d06837c04c4966d8eb9e81c2e5f2135bd003b36 Mon Sep 17 00:00:00 2001 From: Tymi Date: Wed, 7 Jan 2026 22:17:32 +0100 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=8E=A8=20Fix=20clang-format=20for=20f?= =?UTF-8?q?ile=5Fsize=20in=20IOCP=20I/O=20engine=20implementation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/io_engine_iocp.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/io_engine_iocp.cpp b/src/io_engine_iocp.cpp index 9efa6d9..8cdf41e 100644 --- a/src/io_engine_iocp.cpp +++ b/src/io_engine_iocp.cpp @@ -710,8 +710,7 @@ namespace asyncpp::io::detail { uint64_t io_engine_iocp::file_size(file_handle_t fd) { LARGE_INTEGER file_size{}; - if (GetFileSizeEx(fd, &size) == FALSE) - throw std::system_error(GetLastError(), std::system_category()); + if (GetFileSizeEx(fd, &size) == FALSE) throw std::system_error(GetLastError(), std::system_category()); return file_size.QuadPart; } From 6f1d1e21bf375c5c0111ebbdacbc18af54e1ac84 Mon Sep 17 00:00:00 2001 From: Dominik Thalhammer Date: Thu, 8 Jan 2026 10:45:07 +0100 Subject: [PATCH 3/3] Update io_engine_iocp.cpp --- src/io_engine_iocp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/io_engine_iocp.cpp b/src/io_engine_iocp.cpp index 8cdf41e..74c700d 100644 --- a/src/io_engine_iocp.cpp +++ b/src/io_engine_iocp.cpp @@ -710,7 +710,7 @@ namespace asyncpp::io::detail { uint64_t io_engine_iocp::file_size(file_handle_t fd) { LARGE_INTEGER file_size{}; - if (GetFileSizeEx(fd, &size) == FALSE) throw std::system_error(GetLastError(), std::system_category()); + if (GetFileSizeEx(fd, &file_size) == FALSE) throw std::system_error(GetLastError(), std::system_category()); return file_size.QuadPart; }