Partager via


_FFlush( ) API Library Routine

Flushes to disk all modified buffers in memory for the specified file.

int _FFlush(FCHAN chan)
FCHAN chan;               /* File channel of file to flush. */

Remarks

_FFlush( ) returns 0 if it is successful in flushing the buffers, 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 creates a file and sets its length to 8196 bytes. Executing the Visual FoxPro command line DIR TEMP.TXT in the Command window shows that the size of the file on disk is still 0. However, after executing = XFFLUSH( ), issuing the command line DIR TEMP.TXT shows that the file on disk reflects the _FCHSize( ) call, and has a file size of 8196 bytes.

Visual FoxPro Code

SET LIBRARY TO FFLUSH  
DIR temp.txt  && size on disk is still 0
WAIT WINDOW "File Size = 0"
= XFFLUSH()
DIR temp.txt  && size on disk is 8196
WAIT WINDOW "File Size Does Not Equal 0"
CLOSE ALL

C Code

#include <pro_ext.h>

static FCHAN fchan;

FAR CreateIt(ParamBlk FAR *parm)
{
   fchan = _FCreate("temp.txt", FC_NORMAL);
   _FCHSize(fchan, 8196);
}

FAR FFlushEx(ParamBlk FAR *parm)
{
   _FFlush(fchan);
}

FoxInfo myFoxInfo[] = {
   {"ONLOAD", (FPFI) CreateIt, CALLONLOAD, ""},
   {"XFFLUSH", (FPFI) FFlushEx, 0, ""},
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};

See Also

Reference

_FPuts( ) API Library Routine

_FWrite( ) API Library Routine

_FError( ) API Library Routine

Other Resources

API Library Construction

Accessing the Visual FoxPro API