CloseCtFile
Close index or data file.
Short Name
CLSFIL()
Type
Low-Level file function
Declaration
COUNT CloseCtFile(FILNO filno, COUNT filmod)
Description
In V12 the file number typedef was formally changed from COUNT, a two-byte value to FILNO, a four-byte value. Refer to this link for compatibility details. Four Byte File Numbering
CloseCtFile() closes file number filno.
The filmod parameter is no longer used. It has been left in this definition solely for the sake of compatibility with older versions. If you have programs that were developed with older versions of FairCom DB, you don’t have to change your CloseCtFile() function calls. For newer programs, you can leave it out, unless you are using function prototyping and receive a warning about having too few parameters. In this case either use a second parameter, which will be ignored, or change the function prototype definition in ctdecl.h.
If filno references an index file with additional index members, CloseCtFile() closes the primary index and its members.
CloseCtFile() ensures a file is properly closed so updates will be properly saved to disk. In Low-Level mode, data files are updated by NewData(), ReleaseData(), and WriteData(), and index files are updated by AddKey(), DeleteKey(), and DeleteKeyBlind().
Return
Value |
Symbolic Constant |
Explanation |
---|---|---|
0 |
NO_ERROR |
Successful file close. |
22 |
FNUM_ERR |
File number out of range. |
24 |
FCLS_ERR |
Could not close file number isam_fil. |
26 |
FACS_ERR |
File number is not assigned to a file in use. |
See FairCom DB Error Codes for a complete listing of valid FairCom DB error values.
Example
FILNO filno = 0;
COUNT retval;
TEXT filnam[15] = "sample.dat";
if (retval = InitCtree(6,7,4))
printf("\nCould not initialize. Error %d.", retval);
else {
if (OpenCtFile(filno, filnam, (ctSHARED | ctVIRTUAL | ctFIXED)))
printf("\nCould not open file.");
else if (CloseCtFile(filno, 0))
printf("\nCould not close file.");
if (CloseISAM())
printf("\nCould not close ISAM.");
}
See also
NewData, ReleaseData, WriteData, AddKey, DeleteKey, DeleteKeyBlind, OpenCtFile, CreateDataFile, CreateIndexFile