FreeBASIC  0.91.0
file_tell.c
Go to the documentation of this file.
1 /* TELL() and TELL */
2 
3 #include "fb.h"
4 
5 /*:::::*/
7 {
8  fb_off_t pos;
9 
10  if( !FB_HANDLE_USED(handle) )
11  return 0;
12 
13  FB_LOCK();
14 
15  if (handle->hooks->pfnTell != NULL) {
16  if (handle->hooks->pfnTell( handle, &pos )!=0) {
17  pos = -1;
18  }
19  } else {
20  pos = -1;
21  }
22 
23  if (pos != -1) {
24  /* Adjust real position by number of characters in put back buffer */
25  pos -= handle->putback_size;
26 
27  /* if in random mode, divide by reclen */
28  if( handle->mode == FB_FILE_MODE_RANDOM )
29  pos /= handle->len;
30 
31  }
32 
33  FB_UNLOCK();
34 
35  return pos + 1;
36 }
37 
38 /*:::::*/
39 FBCALL long long fb_FileTell( int fnum )
40 {
41  return fb_FileTellEx( FB_FILE_TO_HANDLE(fnum) );
42 }