beautypg.com

Rename, Tell – Argox PA-20 Programming Guide User Manual

Page 47

background image

PT-20 Programming Guide

45

fErrorCode: 1:filename is a NULL string.

2:File specified by filename does not exist.

_rename

Purpose: Change file name of an existing file.

Syntax: int _rename(char *old_filename, char *new_filename);

Example call:

if (_rename(“C:\\data\\store.dat”,” C:\\data\\text.dat”)

_put

s(“store.dat renamed”);

Includes:

#include “SDK.h ”

Description: Change the file name of the file specified by old_filename to

new_filename. But the route does not change.

Returns: If rename successfully changes the file name, it returns an integer

value of 1. In case of error, rename 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.

fErrorCode: 1:Either old_filename or new_filename is a NULL string.

2:File specified by old_filename does not exist.

3:A file with file name new_filename already exists.

4:File path is error

5:Filename is too long.

6:File is using.

7:Filename is error

8:Other error

tell

Purpose: Get file pointer position of a DAT file.

Syntax: long tell(int fd);

Example call: current_position = tell(fd);

Includes:

#include “SDK.h ”

Description: The tell function returns the current file pointer position of the

DAT file whose file handle is specified in the argument fd. The

file pointer position is expressed in number of bytes from the

beginning of file. For instance, if the file pointer points to the

beginning of file, the file pointer position will be 0.

Returns: The long integer value returned by tell is the current file pointer

position in file. In case of error, tell returns a long 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.