1 /*-------------------------------------------------------------------------
4 * Implementation of pread(2) for Windows.
6 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
9 * src/port/win32pread.c
11 *-------------------------------------------------------------------------
20 pg_pread(int fd
, void *buf
, size_t size
, off_t offset
)
22 OVERLAPPED overlapped
= {0};
26 handle
= (HANDLE
) _get_osfhandle(fd
);
27 if (handle
== INVALID_HANDLE_VALUE
)
33 /* Note that this changes the file position, despite not using it. */
34 overlapped
.Offset
= offset
;
35 if (!ReadFile(handle
, buf
, size
, &result
, &overlapped
))
37 if (GetLastError() == ERROR_HANDLE_EOF
)
40 _dosmaperr(GetLastError());