Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

Multi-User File Mode

When opening a file you can specify the type of shared user access by including the appropriate value in the filmod parameter.

The available file modes are ctEXCLUSIVE, ctSHARED, and ctREADFIL, which can be used with the other file mode parameters. An ctEXCLUSIVE file can only be opened by one user; a ctSHARED file can be opened by multiple users for concurrent read/write access; and a ctREADFIL can be opened by multiple users for read-only access. Two additional file modes, ctCHECKLOCK and ctCHECKREAD, affect record locking, but are specified at the time the file is opened or created in addition to ctSHARED file mode. ctCHECKREAD is available only if you use the FairCom Server, and is discussed in FairCom DB Database Engine.

Note: ctCHECKLOCK and ctCHECKREAD should not be applied to index files.


If a file is opened with a filmod of ctEXCLUSIVE, that file can only be opened by one user. If another user already has the file open in any mode, this user cannot open the file as ctEXCLUSIVE. Once this user has the file opened as ctEXCLUSIVE, no other user can open it. Reads and writes are cached for index files opened with this file mode since there are no integrity issues with only one process in the file.

To support EXCLUSIVE file opens under most Unix systems, add the following line to ctree.mak file or ctopn.h prior to building your library:

#define ctLOCK_EXCLUSIVEfile


Opening a file with a filmod of ctSHARED allows multiple users to have both read and write access to the file. If a user tries to open a file as ctSHARED and another user has the file open as ctEXCLUSIVE or ctREADFIL, this user cannot open the file. Once a user has a file open as ctSHARED, other users can open the file as ctSHARED but not as ctEXCLUSIVE or ctREADFIL.

Note: All files are created in ctEXCLUSIVE mode, even if ctSHARED was in the file mode. Newly created files must be closed and opened again to be shared.


Use this mode if you wish to have multiple users read the file, but you want to prevent them from being able to update the file. A file can only be successfully opened with ctREADFIL if no other process has the file open in ctSHARED or ctEXCLUSIVE mode. Reads are cached for files opened with this file mode. The concept of ctREADFIL is supported by all FairCom Servers and non-Unix FPUTFGET environments. FPUTFGET environments rely on the native operating system interpretation of ctREADFIL, which in Unix typically allows any user to access the file with any file mode (i.e., ctSHARED), but limits ctREADFIL users to read only.