This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch try_fix_python
in repository https://gitbox.apache.org/repos/asf/tsfile.git


The following commit(s) were added to refs/heads/try_fix_python by this push:
     new 159617d2 fix
159617d2 is described below

commit 159617d2bd19c31608735b75615179b6e0a2cc70
Author: HTHou <[email protected]>
AuthorDate: Mon Aug 12 00:13:26 2024 +0800

    fix
---
 cpp/src/file/read_file.cc | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/cpp/src/file/read_file.cc b/cpp/src/file/read_file.cc
index 97385835..40309dde 100644
--- a/cpp/src/file/read_file.cc
+++ b/cpp/src/file/read_file.cc
@@ -135,25 +135,23 @@ int ReadFile::read(int32_t offset, char *buf, int32_t 
buf_size,
 #ifdef _WIN32
 ssize_t pread(int fd, void *buf, size_t count, uint64_t offset)
 {
-    long unsigned int read_bytes = 0;
-
+    DWORD read_bytes = 0;
     OVERLAPPED overlapped;
     memset(&overlapped, 0, sizeof(OVERLAPPED));
 
-    overlapped.OffsetHigh = (uint32_t)((offset & 0xFFFFFFFF00000000LL) >> 32);
-    overlapped.Offset = (uint32_t)(offset & 0xFFFFFFFFLL);
+    overlapped.OffsetHigh = (DWORD)((offset & 0xFFFFFFFF00000000LL) >> 32);
+    overlapped.Offset = (DWORD)(offset & 0xFFFFFFFFLL);
 
     HANDLE file = (HANDLE)_get_osfhandle(fd);
     SetLastError(0);
-    bool RF = ReadFile(file, buf, count, &read_bytes, &overlapped);
+    BOOL RF = ReadFile(file, buf, count, &read_bytes, &overlapped);
 
     // For some reason it errors when it hits end of file so we don't want to 
check that
     if ((RF == 0) && GetLastError() != ERROR_HANDLE_EOF) {
-        errno = GetLastError();
-        // printf ("Error reading file : %d\n", GetLastError());
+        _set_errno(GetLastError());  // Use _set_errno to set the POSIX errno
         return -1;
     }
 
-    return read_bytes;
+    return (ssize_t)read_bytes;
 }
 #endif

Reply via email to