File manipulation, Access, Append – Argox PA-20 Programming Guide User Manual

Page 39: Appendln

Advertising
background image

PT-20 Programming Guide

37

File Manipulation

__access

Purpose: Check for file existence.

Syntax: int __access(char *filename);

Example call:

if(__access(“C:\\data\\store.dat”) _puts(“store.dat exist!!”);

Includes:

#include “SDK.h ”

Description: Check if the file specified by filename.

Returns: If the file specified by filename exist, access returns an integer

value of 1, 0 otherwise. In case of error, access will return 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 theirinterpretation are listed below.

fErrorCode: 1: filename is a NULL string.

append

Purpose: Write a specified number of bytes to bottom (end-of-file position)

of a DAT file.

Syntax: int append(int fd, char *buffer, int count);

Example call:

append(fd,”ABCDE”,5);

Includes:

#include “SDK.h ”

Description: The append function writes the number of bytes specified in the

argument count from the character array buffer to the bottom of a

DAT file whose file handle is fd. Writing of data starts at the

end-of-file position of the file, and the file pointer position is

unaffected by the operation. The append function will

automatically extend the file size of the file to hold the data

written.

Returns: The append function returns the number of bytes actually written

to the file. In case of error, append 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

9 The value of count is negative.

10 No more free file space for file extension.

appendln

Advertising