GetFileInfo

int GetFileInfo (char *fileName, long *fileSize);

Purpose

Verifies whether a file exists. Returns an integer value of zero if no file exists and one if the file exists. fileSize is a long variable that contains the file size in bytes or zero if no file exists.

Example

/* Check for presence of file A:\DATA\TEST1.DAT. */

/* Print its size if file exists or message that states file does not exist. */

int n;
long size;

n = GetFileInfo("a:\\data\\test1.dat",&size);
if (n == 0)
   FmtOut("File does not exist.");
else
   FmtOut("File size = %i[b4]",size);

Parameters

Input
Name Type Description
fileName string Pathname of the file to check.
Output
Name Type Description
fileSize long File size in bytes. fileSize is zero if no file exists.

Return Value

Name Type Description
status integer Indicates whether the specified file exists.

Code Description
1 File exists.
0 File does not exist.
–1 Maximum number of files already open.

You can use GetFmtIOError to get more information about the type of error that occurred.