BLib.Context - Read and Write Filing System Context =================================================== File: Context - Update: 1.01 Author: J.G.Harston - Date: 12-Aug-2011 The Context library provides functions for reading and writing the filing system context independantly of the filing system being used. It allows programs to read the current context, change the current directory and/or filing system, and then restore back to the previous state. Requirements and Dependancies ============================= The library requires a global control block of at least 16 bytes in length to be accessible with X% holding the address of this block, and Y% holding X% DIV 256, and a data block long enough to hold the longest filename likely to be encountered pointed to by name%. This can easily be set up with DIM ctrl% 15, name% 15 near the start of the program and X%=ctrl%:Y%=X%DIV256 at the begining of the major program code and at the start of any main program loop. The library requires the Net and the FileIO libraries. Routine Summary =============== FNfs_RdCSD - Read current filing system context PROCfs_WrCSD(csd%) - Restore filing system context FNfs_RdCSD - Read current filing system context ----------------------------------------------- Returns 0 or a value to pass back to PROCfs_WrCSD(). The returned value encodes the current filing system and the currently selected directory. It is an opaque value and, other than the value zero, should not be interpreted in any way. Zero is returned if the function could not determine the current context. If zero is returned, the CSD path can be found as a string with FNPath_Name in the Pathname library. PROCfs_WrCSD(csd%) - Restore filing system context -------------------------------------------------- On entry, csd%=0 or a previous context from FNfs_RdCSD. The only valid entry values are zero, which is a null operation, or a value previously returned from FNfs_RdCSD. Note, each call to FNfs_RdCSD must be balanced by a corresponding PROCfs_WrCSD, as otherwise open handles may be left hanging around. PROCfs_WrCSD(0) is a valid null operation Examples ======== csd%=FNfs_RdCSD:IF csd%=0:fs%=FNfs:csd$=FNPath_Name *NET *EX *DISK *CAT IF csd%:PROCfs_WrCSD(csd%) ELSE OSCLI "FX143,18,"+STR$fs%:OSCLI "DIR "+csd$ Implementation ============== The Context library currently understands DFS, NFS, ADFS and HADFS. It implicitly understands TAPE and ROMFS as they have no context.