FairCom ISAM for C

Previous Topic

Next Topic

Virtual File Open

The following file modes are related to virtual file open:


Many operating systems and/or C compiler run-time libraries limit the number of files that can be opened at one time. To free the application code from worries over the number of files opened at one time, c-tree implements two types of file opens: ctPERMANENT and ctVIRTUAL. A permanent file open causes the file to be opened and stay open until the program executes a file close. This is the traditional type of file open. A virtual file open causes the file to be opened, but allows it to be transparently closed and reopened in order to allow other virtual files to be used.

When it is necessary for a virtual file to be temporarily closed, c-tree selects the least recently used virtual file. This file will remain closed until it is next used, at which time it will be automatically reopened. This strategy causes c-tree to use all available file descriptors.

This activity is transparent to both the user and the programmer. You do not have to treat virtual files any differently than you would a permanent file. There are only two effects from using virtual files:

  • The user may notice a slowdown in performance when the virtual files are being opened and closed.
  • The programmer will be less likely to have to deal with run-time errors caused when more files are opened than the operating environment supports.

Applications that need more files open will run into this limit. By setting the filmod of some of the files to ctVIRTUAL, c‑tree allows the application to have more files open than the limit. Alternatively, some compilers provide a way to increase the number of file handles available to an application. This option is advisable in Standalone Multi-user applications using a large number of files. Consult your compiler documentation for instructions on increasing the file handle limit.