Commit c65b4ea9 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

(Almost) pread() for Win32

parent 1ba9301e
...@@ -228,6 +228,25 @@ block_t *block_mmap_Alloc (void *addr, size_t length) ...@@ -228,6 +228,25 @@ block_t *block_mmap_Alloc (void *addr, size_t length)
} }
#endif #endif
#ifdef WIN32
static
ssize_t pread (int fd, void *buf, size_t count, off_t offset)
{
HANDLE handle = (HANDLE)(intptr_t)_get_osfhandle (fd);
if (handle == INVALID_HANDLE_VALUE)
return -1;
OVERLAPPED olap = { .Offset = offset, .OffsetHigh = (offset >> 32), };
DWORD written;
/* This braindead API will override the file pointer even if we specify
* an explicit read offset... So do not expect this to mix well with
* regular read() calls. */
if (ReadFile (handle, buf, count, &written, &olap))
return written;
return -1;
}
#endif
/***************************************************************************** /*****************************************************************************
* block_fifo_t management * block_fifo_t management
*****************************************************************************/ *****************************************************************************/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment