Chapter 3 Terminal Specific Function Library
191
delete_top
Purpose
To delete a specified number of bytes from the top (beginning-of-file position)
of a DAT file.
Syntax
int delete_top (int fd, int count);
int fd; /* file handle of the target DAT file */
int count; /* number of bytes to be deleted */
Example
delete_top (fd, 80);
Description
This routine deletes the number of bytes (
count
) from a DAT file (
fd
).
Removal of data starts at the beginning-of-file position of the file, and the
file pointer position is adjusted accordingly.
For example, if initially the file pointer points to the tenth character, after
deleting eight characters from the file, the new file pointer will points to
the 2nd character of the file.
This routine will resize the file size automatically.
Return
If successful, it returns the number of bytes actually removed from the file.
On error, it returns -1.
An error code is set to the global variable fErrorCode to indicate the error
condition encountered. Below are possible error codes and their interpretation.
Error Code
Interpretation
2
File specified by
fd
does not exist.
4
File specified by
fd
is not a DAT file.
7
Invalid file handle.
8
File not opened.
9
The value of
count
is negative.
See Also
delete_topln
delete_topln
Purpose
To delete a line (null-terminated string) from the top (beginning-of-file
position) of a DAT file.
Syntax
int delete_topln (int fd);
int fd; /* file handle of the target DAT file */
Example
delete_topln (fd);
Description
This routine deletes a null-terminated string specified from a DAT file (
fd
).
Characters are removed from the file until a null character (\0) or
end-of-file is encountered. The null character is also removed from the
file.
Summary of Contents for Optimus R
Page 1: ...Printed on 20 March 2006 C Programming Guide Version 3 04 02 Optimus S Optimus R...
Page 6: ......
Page 8: ...2 C Programming Guide For Optimus S R...
Page 12: ...6 C Programming Guide For Optimus S R The flow is illustrated as shown below...
Page 23: ...Chapter 2 Development Environment 17 Different types signed unsigned Different types same size...
Page 24: ...18 C Programming Guide For Optimus S R...
Page 220: ...214 C Programming Guide For Optimus S R See Also FlashSize free_memory...