You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Current »

When executing record-oriented calls such as READ.RECORD and WRITE.RECORD, the MFS does not know the OpenInsight file name of the file it is accessing. The only file information available to the MFS at the time is the file handle.

Some MFSs require access to the name of the file as seen by users. For instance, an audit trail MFS will likely wish to stamp the OpenInsight file name on entries in the log. Many MFSs must also use the file name, or information based on it, to open and access related files. An example is SI.MFS, which must open the ! file associated with a data file.


Maintaining a Filename Table

Yet another means for tracking the OpenInsight file name is for the MFS to maintain a table of file names and handles. This method is useful if the MFS programmer does not wish to carry the filename on the file handle for fear of interfering with other filing systems.

One strategy is to create a labelled common area in the MFS.  In a simple scenario, the common area contains two dynamic arrays, one for file names and one for file handles.

When a file is first opened, the MFS traps both the file name and the file handle after the BFS has returned these. The MFS stores the file name in one array, and the file handle in the corresponding location in the second array. When access to the file name is required, the MFS can locate the file handle in its array, and extract the corresponding file name.

Because the file handle can change during a session -- for example, if a file has an MFS added and is reattached -- the file handle is updated in the labelled common area each time the file is opened.

The following example code fragment illustrates a method to establish the arrays. In this example, the file name is stored as passed to the MFS, in the format filename*application.

COMMON /FILENAME/ FILES.ARRAY,HANDLES.ARRAY
(other processing here)
OPEN.FILE:
* call BFS in order to get file handle
FS = DELETE(BFS,1,1,1)
NEXTFS = FS<1,1,1>
CALL @NEXTFS(CODE, FS, HANDLE, NAME, FMC,RECORD, STATUS)
* load handle and file name into labelled
common
IF STATUS THEN
  LOCATE NAME IN FILES.ARRAY USING @FM SETTING POS THEN
    HANDLES.ARRAY<POS> = RECORD
  END ELSE
    FILES.ARRAY<-1> = NAME
    HANDLES.ARRAY<-1> = RECORD
  END
END
RETURN

Once the arrays have been established, the MFS can extract the file name at any time that it has the file handle available.  The following code fragment illustrates a method by which the READ.RECORD logic might extract the file name:

READ.RECORD:
* search handle array to get position
LOCATE HANDLE IN HANDLES.ARRAY USING @FM SETTING POS THEN
  * extract corresponding file name
  FILE.NAME = FILES.ARRAY<POS>
END
FS = DELETE(BFS,1,1,1)
NEXTFS = FS<1,1,1>
CALL @NEXTFS(CODE, FS, HANDLE, NAME,FMC, RECORD, STATUS)
RETURN
  • No labels