Atari ST series Technical Reference Manual page 126

Hide thumbs Also See for ST series:
Table of Contents

Advertisement

Table 6-4. Meaning of Flag Bits Used in File Creation (continued)
Bit
Bit
Number
Value
2
4
3
8
If the file didn't exist previously, Fcreate() both creates a
directory entry for the new file and opens it for writing only.
If the function succeeds, the file handle of the new file is re­
turned in handle. If not, a negative GEMDOS error number is
returned, such as - 34 (Path Not Found), - 35 (No Handles
Available), or - 3 6 (Access Denied). If the file existed pre­
vious to the Fcreate() call, it will be truncated to a length of
0 before it is opened, which destroys its previous contents.
After the file has been created, it can be written to with
the command Fwrite():
long status, bytes;
int handle;
char *buffer;
status = Fwrite(handle, bytes, buffer);
where handle is the file handle returned when the file was
created or opened, buffer is a pointer to the buffer that holds
the data to write to the file, and bytes indicates the number of
bytes to transfer from the buffer to the file. If the write is suc­
cessful, the number of bytes actually written is returned in status.
If unsuccessful, a GEMDOS error number is returned instead.
When all of the data is written to the file, the file must
be closed with the function Fclose():
int handle, status;
status = Fclose(handle);
where handle is the file handle of the file to close. If the oper­
ation succeeds, 0 is returned in status. Otherwise, it contains
the appropriate GEMDOS error number. Close a file when
you are finished with it because it isn't possible to open the
file for reading or writing again until it's closed.
To read or write to an existing file, you must first open
it. The GEMDOS command used for this purpose is Fo-
p en (), and its calling syntax is as follows:
char *fname;
int handle, mode;
handle = Fopen(fname, mode);
CHAPTER 6
Description
System file (excluded from normal directory
searches)
Volume label (can only exist in root)

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents