GEOS SDK TechDocs
|
|
3.6 Accessing and Altering VM Blocks
|
3.8 Updating and Saving Files
VMVMBlockToMemBlock(), VMMemBlockToVMBlock(), VMInfo()
Several utilities are provided to give you information about VM blocks.
If you know the handle of a VM block, you can find out the handle of the associated global block by calling the routine
VMVMBlockToMemBlock()
. This routine takes two arguments, namely the VM file handle and the VM block handle. It returns the global memory handle of the associated block; however, note the caveats regarding global handles in the above section. If the VM block is not currently associated with a global memory block, the routine will allocate a memory block, copy the VM block into it, and return its handle. If the VM handle is not associated with any data in the file and is not attached to a global memory block,
VMVMBlockToMemBlock()
returns a null handle.
Conversely, if you know the handle of a global memory block and want to find out the VM file and block to which it is attached, call the routine
VMMemBlockToVMBlock()
. This routine takes two arguments: the global memory handle, and a pointer to a
VMFileHandle
variable. It returns the VM block handle of the associated VM block, and writes the handle of the VM file to the address passed. If the global memory block is not attached to a VM file, it returns null handles.
The Boolean routine
VMInfo()
is an omnibus information routine. It takes three arguments: the handle of a VM file, the handle of a VM block, and a pointer to a
VMInfoStruct
structure (described below in VMInfoStruct
). If the VM block is free, out of range, or otherwise invalid, it returns
false
; otherwise, it returns
true
(i.e. non-zero) and fills in the fields of the
VMInfoStruct
.
Code Display 18-1 VMInfoStruct
/* This is the definition of the VMInfoStruct. A pointer to a VMInfoStruct is
* passed to the routine VMInfo(). The routine fills in the structure's fields.
*/
typedef struct {
MemHandle mh; /* Null handle returned if no block is attached */
word size; /* Size of VM block in bytes */
word userID; /* User ID (or zero if no user ID was specified) */
} VMInfoStruct;
GEOS SDK TechDocs
|
|
3.6 Accessing and Altering VM Blocks
|
3.8 Updating and Saving Files