F.31 CreateIFile
Incremental ISAM create.
Short Name
CREIFIL
TYPE
ISAM function
DECLARATION
COUNT CreateIFile(pIFIL ifilptr)DESCRIPTION
CreateIFile creates the data file and (optional) index file referenced by the IFIL structure pointed to by ifilptr. The file name pointed to by the IFIL structure, ifilptr- >pfilnam, should NOT include an extention: ".dat" and ".idx" are automatically appended to the file name for the data file and index file, respectively. The extended version of this function, CreateIFileXtd, can change the file extentions at run time.
If you desire the files to be created in directories that are not specified until run-time, then ifilptr- >pfilnam should not be finalized until run-time.
Consecutive file numbers are assigned to the data file and any (optional) indices associated with the data file. The IFIL structure contains two file numbers: a permanent file number (dfilno), and a temporary file number (tfilno). If dfilno is less than zero, c-tree Plus finds the first available block of sufficient consecutive file numbers. If such a block of numbers is found, then the first number in the block is assigned to the data file and to tfilno. If dfilno is greater than or equal to zero, then dfilno is assigned to the data file and to tfilno.
Unless Resources are disabled for this file, CreateIFile automatically stores the IFIL definition in the file as a resource. This permits OpenFileWithResource to open the entire IFIL set simply by file name.
RETURN
Upon successful create, ifilptr->tfilno contains the file number assigned to the data file; and the associated indices are assigned consecutive index numbers starting one (1) greater than the data file number.
See Appendix A "c-tree Plus Error Codes" of the c-tree Plus Programmer's Reference Guide for a complete listing of valid c-tree Plus error values.
EXAMPLE
extern IFIL myfile;COUNT retval;if (retval = InitISAM(6,7,4))printf("\nCould not close files. Error %d.", retval);else {if (CreateIFile(&myfile))printf("\nCould not create %s (%d,%d)\n",myfile- >pfilname, isam_err, isam_fil);else if (CloseIFile(&myfile))printf("\nCould not close files.");if (OpenIFile(&myfile))printf("\nCould not open files.");else if (CloseIFile(&myfile))printf("\nCould not close files.");if (CloseISAM())printf("\nCould not close ISAM.");}LIMITATIONS
The index files will be numbered consecutively following the data file. See "File numbering" in the index for additional information.
While CreateIFile can mark files for shared use, they is not created in the shared mode. In order to use files in the shared mode, they must first be created, then closed, then opened with a shared file mode.
SEE ALSO
InitISAM, OpenIFile, CloseISAM, CreateIFileXtd, OpenFileWithResource, GetIFile and the Chapter 5 "ISAM Functions" of the c-tree Plus Programmer's Reference Guide, which describes the ISAM parameters.
|
FairCom Corporation www.faircom.com |