FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
file_seek.c
Go to the documentation of this file.
1
/* SEEK() and SEEK */
2
3
#include "
fb.h
"
4
5
int
fb_FileSeekEx
(
FB_FILE
*
handle
,
fb_off_t
newpos )
6
{
7
int
res;
8
9
if
( !
FB_HANDLE_USED
(handle) )
10
return
fb_ErrorSetNum
(
FB_RTERROR_ILLEGALFUNCTIONCALL
);
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
{
25
res =
fb_ErrorSetNum
(
FB_RTERROR_ILLEGALFUNCTIONCALL
);
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
}
rtlib
file_seek.c
Generated on Thu Jan 23 2014 19:40:11 for FreeBASIC by
1.8.4