]> pd.if.org Git - pdclib/blob - platform/win32/functions/_PDCLIB/_PDCLIB_seek.c
_PDCLIB_flushbuffer for win32. correct seeking behaviour.
[pdclib] / platform / win32 / functions / _PDCLIB / _PDCLIB_seek.c
1 /* $Id$ */
2
3 /* int64_t _PDCLIB_seek( FILE *, int64_t, int )
4
5    This file is part of the Public Domain C Library (PDCLib).
6    Permission is granted to use, modify, and / or redistribute at will.
7 */
8
9 #include <stdio.h>
10 #include <errno.h>
11 #ifndef REGTEST
12 #include <_PDCLIB_glue.h>
13 #include <windows.h>
14
15 extern void _PDCLIB_w32errno( void );
16 _PDCLIB_int64_t _PDCLIB_seek( struct _PDCLIB_file_t * stream, _PDCLIB_int64_t offset, int whence )
17 {
18     LARGE_INTEGER liOffset;
19     liOffset.QuadPart = offset;
20     BOOL rv = SetFilePointerEx( stream->handle, liOffset, &liOffset, whence );
21     if(!rv) {
22         _PDCLIB_w32errno();
23         return EOF;
24     }
25     stream->pos.offset = liOffset.QuadPart;
26     return liOffset.QuadPart;
27 }
28
29 #endif
30
31 #ifdef TEST
32 #include <_PDCLIB_test.h>
33
34 int main( void )
35 {
36     /* Testing covered by ftell.c */
37     return TEST_RESULTS;
38 }
39
40 #endif
41