PostgreSQL Source Code  git master
win32pread.c File Reference
#include "c.h"
#include <windows.h>
Include dependency graph for win32pread.c:

Go to the source code of this file.

Functions

ssize_t pg_pread (int fd, void *buf, size_t size, off_t offset)
 

Function Documentation

◆ pg_pread()

ssize_t pg_pread ( int  fd,
void *  buf,
size_t  size,
off_t  offset 
)

Definition at line 20 of file win32pread.c.

21 {
22  OVERLAPPED overlapped = {0};
23  HANDLE handle;
24  DWORD result;
25 
26  handle = (HANDLE) _get_osfhandle(fd);
27  if (handle == INVALID_HANDLE_VALUE)
28  {
29  errno = EBADF;
30  return -1;
31  }
32 
33  /* Note that this changes the file position, despite not using it. */
34  overlapped.Offset = offset;
35  if (!ReadFile(handle, buf, size, &result, &overlapped))
36  {
37  if (GetLastError() == ERROR_HANDLE_EOF)
38  return 0;
39 
40  _dosmaperr(GetLastError());
41  return -1;
42  }
43 
44  return result;
45 }
static char * buf
Definition: pg_test_fsync.c:67
static int fd(const char *x, int i)
Definition: preproc-init.c:105
void _dosmaperr(unsigned long)
Definition: win32error.c:177

References _dosmaperr(), buf, and fd().