Atari ST series Technical Reference Manual page 128

Hide thumbs Also See for ST series:
Table of Contents

Advertisement

pointer wherever you want in the file by using the Fseek()
function. Fseek() is called like this:
long position, offset;
int handle, seekmode;
position = Fseek(offset, handle, seekmode);
Fseek() moves the file pointer for the file referred to by han­
dle by offset number of bytes, in a manner designated by seek­
mode. The movement of the file pointer is made relative to
one of three points:
• The beginning of the file
• The end of the file
• The current file pointer position
The seekmode specifies where the move begins:
Seekmode
File Pointer Movement
0
Relative to beginning of file
1
Relative to current position
2
Relative to end of file
The offset is a signed number that moves the pointer a
positive or negative number of bytes from its starting point.
If offset is positive, the pointer moves toward the end of the
file. If negative, it moves towards the beginning. For exam­
ple, if seekmode is 0 and offset is 100, the file pointer is set to
byte 100 of the file, and the next read starts with byte 101. If
seekmode is 1 and offset is -1 0 0 , the file pointer moves back
100 bytes from its current position. After the Fseek() call, the
absolute current position of the file pointer (expressed as an
offset from the beginning of the file) is returned in position.
Therefore, when you call Fseek() with a seekmode of 2 and an
offset of 0, the length of the file is returned in position.
Program 6-1 demonstrates many of the file I/O functions
explained above. It writes out a short test file to the floppy
disk, reads it back, changes it, and reads it again.
Program 6-1. GFILEIO.C
/*****************************************
/*
/*
GFILEIO.C
/*
/*
Demonstrates the GEMDOS file-creation,
/*
write, read, and close functions
/* /*****************************************
120
CHAPTER 6
V
*/
*/
* /
*/
*/
*/

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents