Assigns a Visual FoxPro channel to a new file.
FCHAN _FCreate(char FAR *filename, int mode) char FAR *filename; /* Name of file to create. */ int mode; /* File attributes. */ |
Remarks
If a file with the specified name already exists, _FCreate(В ) truncates the existing file to zero bytes.
The mode parameter may be one or more of the following flags: FC_READONLY, FC_SYSTEM, FC_HIDDEN, and FC_TEMPORARY. You can combine these flags using the C or + operator. An additional flag, FC_NORMAL, specifies that the file has none of the other attributes. FC_TEMPORARY files are automatically deleted when you call _FClose(В ) to close the file.
_FCreate( ) returns the file channel if it succeeds in creating the file, or – 1 if it fails.
For more information on how to create an API library and integrate it with Visual FoxPro, see Accessing the Visual FoxPro API.
Example
The following example uses _FCreate(В ) to create a number of files using the various mode flags of _FCreate(В ).
Visual FoxPro Code
В | Copy Code |
---|---|
SET LIBRARY TO FCREATE |
C Code
В | Copy Code |
---|---|
#include <pro_ext.h> FAR Example(ParamBlk FAR *parm) { FCHAN fchan; fchan = _FCreate("normal.tmp", FC_NORMAL); _FClose(fchan); fchan = _FCreate("readonly.tmp", FC_READONLY); _FClose(fchan); fchan = _FCreate("hidden.tmp", FC_HIDDEN); _FClose(fchan); fchan = _FCreate("system.tmp", FC_SYSTEM); _FClose(fchan); fchan = _FCreate("temp.tmp", FC_TEMPORARY); _FClose(fchan); fchan = _FCreate("multi.tmp", FC_SYSTEM | FC_READONLY); _FClose(fchan); } FoxInfo myFoxInfo[] = { {"FCREATE", (FPFI) Example, CALLONLOAD, ""}, }; FoxTable _FoxTable = { (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo }; |