PT-20 Programming Guide
38
Purpose
:
Write a null terminated character string to the bottom
(end-of-file position) of a DAT file.
Syntax
:
int appendln(int fd, char *buffer);
Example call
:
appendln(fd, data_buffer);
Includes
:
#include “SDK.h ”
Description
:
The appendln function writes a null terminated character string
from the character array buffer to a DAT file whose file handle is
fd. Characters are written to the file until a null character (\0) is
encountered. The null character is also written to the file. Writing
of data starts at the end-of-file position. The file pointer position
is unaffected by the operation. The appendln function will
automatically extend the file size of the file to hold the data
written.
Returns
:
The appendln function returns the number of bytes actually
written to the file (includes the null character). In case of error,
appendln returns an integer value of -1 and an error code is set to
the global variable fErrorCode to indicate the error condition
encountered. Possible error codes and their interpretation
are listed below.
fErrorCode
:
2:File specified by fd does not exist.
8:File not opened
10:No more free file space for file extension.
11:Can not find string treminator in buf.
chsize
Purpose
:
Extends or truncates a DAT file.
Syntax
:
int chsize(int fd, long new_size);
Example call
:
if (chsize(fd, 0)) _puts(“file truncated!\n”);
Includes
:
#include “SDK.h ”
Description
:
The chsize function truncates or extends the file specified by the
argument fd to match the new file length in bytes given in the
argument new_size. If the file is truncated, all data beyond the
new file size will be lost. If the file is extended, no initial value is
filled to the newly extended area.
Returns
:
If chsize successfully changes the file size of the specified DAT
file, it returns an integer value of 1. In case of error, chsize will
return an integer value of 0 and an error code is set to the global
variable fErrorCode to indicate the error condition encountered.
Possible error codes and their interpretation are listed below.