FreeBASIC  0.91.0
file_seek.c
Go to the documentation of this file.
1 /* SEEK() and SEEK */
2 
3 #include "fb.h"
4 
6 {
7  int res;
8 
9  if( !FB_HANDLE_USED(handle) )
11 
12  FB_LOCK();
13 
14  /* clear put back buffer for every modifying non-read operation */
15  handle->putback_size = 0;
16 
17  /* convert to 0 based file i/o */
18  --newpos;
19  if( handle->mode == FB_FILE_MODE_RANDOM )
20  newpos = newpos * handle->len;
21 
22  if (handle->hooks->pfnSeek!=NULL) {
23  res = handle->hooks->pfnSeek(handle, newpos, SEEK_SET );
24  } else {
26  }
27 
28  FB_UNLOCK();
29 
30  return res;
31 }
32 
33 FBCALL int fb_FileSeek( int fnum, int newpos )
34 {
35  return fb_FileSeekEx( FB_FILE_TO_HANDLE(fnum), newpos );
36 }
37 
38 FBCALL int fb_FileSeekLarge( int fnum, long long newpos )
39 {
40  return fb_FileSeekEx( FB_FILE_TO_HANDLE(fnum), newpos );
41 }