vacuumlazy.c: Tweak local variable name.
[pgsql.git] / src / port / win32pwrite.c
blob5dd10821cfbbcfe6cbf18eefd18976bf8a560840
1 /*-------------------------------------------------------------------------
3 * win32pwrite.c
4 * Implementation of pwrite(2) for Windows.
6 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
8 * IDENTIFICATION
9 * src/port/win32pwrite.c
11 *-------------------------------------------------------------------------
15 #include "c.h"
17 #include <windows.h>
19 ssize_t
20 pg_pwrite(int fd, const void *buf, size_t size, off_t offset)
22 OVERLAPPED overlapped = {0};
23 HANDLE handle;
24 DWORD result;
26 handle = (HANDLE) _get_osfhandle(fd);
27 if (handle == INVALID_HANDLE_VALUE)
29 errno = EBADF;
30 return -1;
33 /* Note that this changes the file position, despite not using it. */
34 overlapped.Offset = offset;
35 if (!WriteFile(handle, buf, size, &result, &overlapped))
37 _dosmaperr(GetLastError());
38 return -1;
41 return result;