The Virtual File System

Top  Previous  Next

 

The Virtual File System (VFS) allows application designers to provide access to data that appears to an application as a file but may actually be something quite different. Possible uses of the VFS include:

 

Providing access to data in other database environments.
Accessing data transparently over a network where QMNet is not appropriate.
Implementing an alternative encryption layer on top of standard QM files.

 

 

The VFS Handler Class Module

 

A VFS handler is a globally catalogued QMBasic class module that intercepts all attempts to access the file. It processes requests, storing or retrieving data as appropriate.

 

A template class module named VFS.CLS is provided in the BP file of the QMSYS account. This includes a brief description of each of its component functions and subroutines.

 

 

Creating a Virtual File System

 

There are two steps; creating the VFS handler and creating the VOC entries.

 

Like all files, a VFS file is identified by an F-type VOC item. It is possible for only some parts of a file to be VFS items. Thus a file might have a VFS data part but a normal dictionary part.  The components of a multifile can be a mix of VFS and normal items.

 

A VFS item is identified by the pathname in the F-type VOC entry being specified as "VFS:handler" where handler is the name of the globally catalogued VFS handler class module. There is an optional third component to this syntax which will be passed to the handler on opening the VFS item. The full syntax of the VOC item is thus

VFS:handler:string

This third component could be used, for example, when a single handler class module is used to access many files. The string might be the pathname or other reference to the actual file to be opened by the handler.

 

 

Partial Select Lists

 

The QM file system optimises select list generation by arranging that the QMBasic SELECT statement (not the query processor equivalent) used against a hashed file actually performs the select group by group as the READNEXT statement is used to walk through the list. Anything that requires the list to be completed (e.g. using SELECTINFO() to determine the number of items in the list) will cause the remainder of the list to constructed immediately.

 

A VFS handler can work in much the same way. The V$SELECT function can return the entire list or just the initial part of the list. When a program processing this list reaches the end of the list returned by V$SELECT, the V$CONTINUE.SELECT function is called to return the next part of the list. The V$COMPLETE.SELECT function will be called if the remainder of the list should be returned as a single item and the V$END.SELECT subroutine is called to terminate generation of a partial list.

 

VFS handlers that do not use partial list construction can omit the V$CONTINUE.SELECT, V$COMPLETE.SELECT and V$END.SELECT entry points.

 

 

Alternate Key Indices

 

The Virtual File System does not support alternate key indices at this release. The INDICES(), SELECTINDEX, SELECTLEFT, SELECTRIGHT, SETLEFT and SETRIGHT operations are not valid with a VFS item.