[vlc-devel] commit: (Almost) pread() for Win32 ( Rémi Denis-Courmont )
git version control
git at videolan.org
Tue May 20 22:18:19 CEST 2008
vlc | branch: master | Rémi Denis-Courmont <rem at videolan.org> | Tue May 20 22:57:54 2008 +0300| [c65b4ea96c47550a8876513222aab4b81cfc42dd]
(Almost) pread() for Win32
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c65b4ea96c47550a8876513222aab4b81cfc42dd
---
src/misc/block.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/src/misc/block.c b/src/misc/block.c
index eeee4ed..fe78ec2 100644
--- a/src/misc/block.c
+++ b/src/misc/block.c
@@ -228,6 +228,25 @@ block_t *block_mmap_Alloc (void *addr, size_t length)
}
#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
*****************************************************************************/
More information about the vlc-devel
mailing list