<< Click to Display Table of Contents >>

 

zetafax_logo

ZfxCreateAutoFile

 


 

Creates file name with unique body.

 

Syntax

 

ZFERR FAR ZfxCreateAutoFile( ZFSESSIONHANDLE hSession, char FAR *lpszPrefix,  char FAR *lpszExtn, char FAR *lpszPath, char FAR *lpszBody)

 

Parameters

 

Parameter

Description

hSession

API session handle, as returned by ZfxAPIInit  call lpszPrefix4 character identifier for filelpszExtn1 to 3 character extension for file

lpszPath

Full pathname of directory to contain filelpszBodyAddress of buffer (of length ZFMSG_BODY_LEN+1) to receive body  name of file which is created (returned)

 

Description

 

This routine creates a file in the given directory, where no other file in the  directory has the same body name (ie the part of the file name excluding the  extension). The file name created has the form "~ppppnnn.xxx" where pppp and  xxx are the prefix name and extension specified in the call, and nnn is a  number from 000 to 999 (or can be 3 alphanumeric characters if the directory  already contains a large number of matching files).

 

The routine is used when creating message files to be sent, since each message has a  unique body name. It is recommended that the first character of the base name  chosen is "X" to guarantee that files created by application programs are not  confused with ones created by the Zetafax client (although this is not  mandatory).

 

Return value

 

The routine returns 0 if successful, otherwise one of the following:

 

ZFERR_NOT_INITIALISED

ZFERR_INVALID_PARAMETERS

ZFERR_PATH_NOT_FOUND

ZFERR_TOO_MANY_FILES

ZFERR_FILE_CREATE_ERROR

 

Example

 

#include  <stdio.h>

#include <zfapi.h>

...

char szBody[ZFMSG_BODY_LEN+1];

char szUserOutDir[256];

if (ZfxGetUserOutDir(hSession, szUserOutDir, sizeof(szUserOutDir)) == 0 && ZfxCreateAutoFile(hSession, "XSUB", "TMP", szUserOutDir, szBody) == 0)

{

       printf("Created file %s%s.TMP\n", szUserOutDir, szBody);

}

 

Related topics

Alphabetical reference

Function error returns and reference