]> pd.if.org Git - pdclib/blobdiff - platform/win32/functions/_PDCLIB/_PDCLIB_seek.c
_PDCLIB_flushbuffer for win32. correct seeking behaviour.
[pdclib] / platform / win32 / functions / _PDCLIB / _PDCLIB_seek.c
index c4c25f87b281829627a943d006101b6f51c5352d..3add6591c535962fc775a9a311759bcb0b64f8de 100644 (file)
 #include <errno.h>
 #ifndef REGTEST
 #include <_PDCLIB_glue.h>
+#include <windows.h>
 
+extern void _PDCLIB_w32errno( void );
 _PDCLIB_int64_t _PDCLIB_seek( struct _PDCLIB_file_t * stream, _PDCLIB_int64_t offset, int whence )
 {
-    errno = ENOTSUP;
-    return EOF;
+    LARGE_INTEGER liOffset;
+    liOffset.QuadPart = offset;
+    BOOL rv = SetFilePointerEx( stream->handle, liOffset, &liOffset, whence );
+    if(!rv) {
+        _PDCLIB_w32errno();
+        return EOF;
+    }
+    stream->pos.offset = liOffset.QuadPart;
+    return liOffset.QuadPart;
 }
 
 #endif