win32pwrite.c File Reference
#include "c.h"
#include <windows.h>
Include dependency graph for win32pwrite.c:
Go to the source code of this file.
ssize_t
pg_pwrite (int
fd, const void *
buf, size_t size, off_t offset)
Function Documentation
◆ pg_pwrite()
ssize_t pg_pwrite
(
int
fd,
const void *
buf,
size_t
size,
off_t
offset
)
Definition at line 20 of file win32pwrite.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 /* Avoid overflowing DWORD. */
34 size =
Min(size, 1024 * 1024 * 1024);
35
36 /* Note that this changes the file position, despite not using it. */
37 overlapped.Offset = offset;
38 if (!WriteFile(handle,
buf, size, &result, &overlapped))
39 {
41 return -1;
42 }
43
44 return result;
45}
static int fd(const char *x, int i)
void _dosmaperr(unsigned long)
References _dosmaperr(), buf, fd(), and Min.