gmSCFileSystemClass
- Mark Juras
Owned by Mark Juras
The FileSystem Service Class
The service class FileSystem interacts with the operating system to form, decompose, and determine file names and attributes so that they conform the requirements of the hosting platform. In addition, it performs several low level file management operations such as searching for files and loading text files into internal text streams. A full filename is viewed as consisting of three components:Component | Description |
pathname | Contains the location within the file system of the file. If it is omitted the the currently selected location is assumed. |
localname | contains the actual name of the file. This is the only component that cannot be omitted. |
extension | contains a short extension that describes the type of the file. If it is omitted then the context is often used to determine its value. |
The method FileSystem_FileName
Prototypeint FileSystem_FileName(char* fileIdent,int nIdent,char* name,int iExt);
Parameter | Description |
fileIdent | Contains the file name to be parsed. It need be null-terminated only if its length is not specified. |
nIdent | Specifies the length of file name. If it is set to zero, then the length is computed. |
name | Receives the localname of the file possibly concatenated with its extension. It is null-terminated. |
iExt | Specifies whether the extension should be included in the returned name. If it is nonzero, then the extension is included in the name. |
This method returns the overall length of the local name.
The method FileSystem_FindFiles
Prototypevoid* FileSystem_FindFiles(char* directory,char* extensions);
Parameter | Description |
directory | Contains the full name of the root directory for the search. |
extensions | Contains a comma-delimited string of the extensions to be searched for. |
The method returns the handle of the local text stream which contains the full filenames. It can be NULL, if it could not be created. It can contain no entries, if no files were found or if the starting directory did not exist.
The method FileSystem_GetDirectory
Prototypeint FileSystem_GetDirectory(char* buffer,char* string,int nString,int remove);
Parameter | Description |
buffer | Receives the directory name extracted from the pathname in null-terminated form. |
string | Contains the full pathname of a file whose directory location is wanted. It need be null-terminated only if nString set to zero. |
nString | Specifies the overall length of the pathname. If set to zero, then the length of the pathname is computed. |
removed | Specifies the number of subdirectory names to be removed from the back of the directory name. |
This method returns the length in characters of the returned directory name.
The method FileSystem_LoadFile
Prototypeint FileSystem_LoadFile(void* Storage,char* filename,int strip);
Parameter | Description | ||||||||||||
Storage | Specifies the handle for the storage area to contain the text buffer. If this handle is NULL, then the text buffer will be allocated to a memory based storage area. If the LoadFile_UseExisting entry flag is set then this parameter Specifies the handle of the text stream. | ||||||||||||
filename | Contains the full filename for the text file whose content is to be loaded. | ||||||||||||
strip | Specifies how records are to be modified and/or stored in the text stream. The
bits this parameter are used as follows:
|
The method returns the root offset of the variable information stream that contains the records of the file if all goes well. If the file cannot be opened with readonly access, then a zero is returned.
The method FileSystem_MakeFullName
Prototypeint FileSystem_MakeFullName(char* path,char* name,int nname,char* ext,char* fullname);
Parameter | Description |
path | Contains the path name to be used. It may be NULL, in which case a local filename is constructed. |
name | Contains the local name of the file. It need not be null-terminated if the nname parameter is not zero. |
nname | Specifies the number of characters in the beginning of the name parameter. If it is zero, then the name string must be null-terminated and its entire content is used. |
ext | Contains the extension to be used. If it is NULL then the filename contains no extension. |
fullname | Receives the full constructed name of the file in null-terminated form. If is up to the user to ensure that it contains sufficient space. |
The method returns the overall length of the filename as constructed.
The method FileSystem_MakeLocalName
Prototypeint FileSystem_MakeLocalName(char* FileName,char* LocalName,int LocalLength,CONST char* Extension,int XtnLength);
Parameter | Description |
FileName | Receives the constructed local filename in null-terminated form. |
LocalName | Contains the local name to be used. This name may already have an extension at its back. This method does not check the front of this name therefore, it may contain a path name as well. |
LocalLength | specifies length of local name. A value of zero means that LocalName is null-terminated and its length is computed. |
Extension | Contains the extension. |
XtnLength | Specifies the length of the extension. If it is zero then Extension is assumed to be null-terminated. |
The method returns the length of the constructed filename.
The method FileSystem_ParseFileName
Prototypeint FileSystem_ParseFileName(char* FileName,int Length,int* LocalStart,int* XtnStart);
Parameter | Description |
FileName | Contains the filename to be parsed. It need be null-terminated only if Length set to zero. |
Length | Specifies the overall length of the filename. If set to zero, then the length of the filename is computed. |
LocalStart | returns the offset of the start of the local name in the filename. A value of zero indicates that the name contains no path name component. |
XtnStart | returns the offset of the start of the extension in the filename. A value of Length indicates that the name had no extension. |
The method returns the overall length of the filename.
The method FileSystem_RelativePathName
Prototypeint FileSystem_RelativePathName(char* parent,char* child,char* relative);
Parameter | Description |
parent | Contains the full pathname of the parent file. |
child | Contains the full pathname of the child file. |
relative | Receives the relative pathname required to reference the child file when in the parent location. |
The method returns the length of the relative name.
Table of Contents