gmslAPI  0.1
gmslAPI: An API for Developing Upgrade Solutions using Great Migrations Technology
gmslLibrary.Services.FileSystem Class Reference

The 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, loading text files into internal text streams, and generating GUIDs. A full file name is viewed as consisting of three components. The pathname contains the location within the file system of the file. If it is omitted the the currently selected location is assumed. The localname contains the actual name of the file. This is the only component that cannot be ommitted. The 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. Note that in the scripting language itself the class is called "System". More...

Static Public Member Functions

static string Directory (string filename, int Remove)
 The Directory method gets the full directory name from a pathname by removing the local filename and a specified number of subdirectories. More...
 
static string Directory (string filename)
 
static bool FileExists (string FileName)
 The FileExists method attempts to open a file with read only shared access to determine if it could be accessed by the current process. More...
 
static string FileName (string pathname)
 The FileName method extracts the local name from a full filename, the extension is included with the name. More...
 
static void FindFiles (Text fileNames, string directory, string extensions)
 The FindFiles method searches the directory tree starting in a specified directory for all files that have some specified number of extensions. The full names of the local files are stored in a text stream. More...
 
static string Guid (string GuidName)
 The Guid method checks the runtime registries for a Guid terminal registry type whose source matches a specified name. The user storage area is checked first, then the language area. More...
 
static int LoadFile (string filename, bool strip)
 The LoadFile method loads the content of a text file into a text stream in storage. Optionally, trailing whitespace is stripped. The file is closed after it has been read. Note that both ASCII and Unicode files can be read by this method. The Unicode is transparently converted to ASCII before loading the records into the text stream. More...
 
static int LoadFile (string filename)
 
static string LocalFileName (string pathname)
 The LocalFileName method extracts the local name from a full filename. Any extension is not included. More...
 
static void LogMessage (string message)
 The LogMessage method appends the specified message to the back of the current logging file. The file is opened, the message is appended, and then the file is closed. Short of major system failures the user can be assured that the last message sent by the application will in fact be in the file – i.e. any internal buffers for the file are flushed on every write. More...
 
static void LogSetName (string fileName, int status)
 The LogSetName method sets the name of the file to receive all subsequent log messages. More...
 
static string MakePathName (string path, string name, string extn)
 The MakePathName method forms a full filename from its components. This method views a file as though it consisted of three concatenated components: path name, local name, and extension. This method constucts the the full name in accordance with the conventions of the platform. More...
 
static string MakeRelativeName (string parentFile, string childFile)
 The MakeRelativeName method creates a relative pathname of a child file as referenced by a parent file, such as a code file being referenced by a project file. More...
 
static int ParseFileName (string FileName, ref int LocalStart, ref int XtnStart)
 The ParseFileName method parses a filename into its components. It views a filename as though it consisted of three concatenated components: path name, local name, and extension. This method computes the relative position within the full name of the start of the local name and the start of the extension. Since the path name is always first, if the local name start is greater than zero, then the beginning of the filename contains a path name. More...
 

Detailed Description

The 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, loading text files into internal text streams, and generating GUIDs. A full file name is viewed as consisting of three components. The pathname contains the location within the file system of the file. If it is omitted the the currently selected location is assumed. The localname contains the actual name of the file. This is the only component that cannot be ommitted. The 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. Note that in the scripting language itself the class is called "System".

Member Function Documentation

◆ Directory()

static string gmslLibrary.Services.FileSystem.Directory ( string  filename,
int  Remove 
)
static

The Directory method gets the full directory name from a pathname by removing the local filename and a specified number of subdirectories.

Parameters
filenamecontains the full pathname of a file whose directory location is wanted.
Removespecifies the number of subdirectory names to be removed from the back of the directory name.
Returns
The derived upper directory name.

◆ FileExists()

static bool gmslLibrary.Services.FileSystem.FileExists ( string  FileName)
static

The FileExists method attempts to open a file with read only shared access to determine if it could be accessed by the current process.

Parameters
FileNamecontains the file name to be checked.
Returns
If the open succeeds the method closes the file and returns true; else it returns false.

◆ FileName()

static string gmslLibrary.Services.FileSystem.FileName ( string  pathname)
static

The FileName method extracts the local name from a full filename, the extension is included with the name.

Parameters
pathnamecontains the file name to be parsed.
Returns
The local name and extension of the file.

◆ FindFiles()

static void gmslLibrary.Services.FileSystem.FindFiles ( Text  fileNames,
string  directory,
string  extensions 
)
static

The FindFiles method searches the directory tree starting in a specified directory for all files that have some specified number of extensions. The full names of the local files are stored in a text stream.

Parameters
fileNamesThe fileNames parameter is the text stream that will receive the file names.
directoryThe directory parameter contains the full name of the root directory for the search.
extensionsThe extensions parameter contains a comma-delimited list of the extensions to be searched for.

◆ Guid()

static string gmslLibrary.Services.FileSystem.Guid ( string  GuidName)
static

The Guid method checks the runtime registries for a Guid terminal registry type whose source matches a specified name. The user storage area is checked first, then the language area.

Parameters
GuidNamecontains the source name for the guid. It may be null or empty.
Returns
If found, the target value is the guid to be used. If not found a new guid is generated via the operating system and returned.

◆ LoadFile()

static int gmslLibrary.Services.FileSystem.LoadFile ( string  filename,
bool  strip 
)
static

The LoadFile method loads the content of a text file into a text stream in storage. Optionally, trailing whitespace is stripped. The file is closed after it has been read. Note that both ASCII and Unicode files can be read by this method. The Unicode is transparently converted to ASCII before loading the records into the text stream.

Parameters
filenamecontains the full filename for the text file whose content is to be loaded.
stripIf true, trailing whitespace is stripped. This is the default.
Returns
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.

◆ LocalFileName()

static string gmslLibrary.Services.FileSystem.LocalFileName ( string  pathname)
static

The LocalFileName method extracts the local name from a full filename. Any extension is not included.

Parameters
pathnamecontains the file name to be parsed.
Returns
The method returns the extracted local name.

◆ LogMessage()

static void gmslLibrary.Services.FileSystem.LogMessage ( string  message)
static

The LogMessage method appends the specified message to the back of the current logging file. The file is opened, the message is appended, and then the file is closed. Short of major system failures the user can be assured that the last message sent by the application will in fact be in the file – i.e. any internal buffers for the file are flushed on every write.

Parameters
messagecontains the message to be logged. The maximum length of a message is 32000 characters. Longer messages will be truncated.

◆ LogSetName()

static void gmslLibrary.Services.FileSystem.LogSetName ( string  fileName,
int  status 
)
static

The LogSetName method sets the name of the file to receive all subsequent log messages.

Parameters
fileNamecontains the name of file to receive messages.
statusspecifies the status code of the message issuing logic: 0 - Issue no message; -1 - Before issuing the next message truncate the file receiving messages; 1 - Write each message to the back of the current logging file.

◆ MakePathName()

static string gmslLibrary.Services.FileSystem.MakePathName ( string  path,
string  name,
string  extn 
)
static

The MakePathName method forms a full filename from its components. This method views a file as though it consisted of three concatenated components: path name, local name, and extension. This method constucts the the full name in accordance with the conventions of the platform.

Parameters
pathcontains the path name to be used. It may be null or empty, in which case a local filename is constructed.
namecontains the local name of the file.
extncontains the extension to be used. If it is null or empty, then the filename contains no extension.
Returns
The method returns the fully formed filename.

◆ MakeRelativeName()

static string gmslLibrary.Services.FileSystem.MakeRelativeName ( string  parentFile,
string  childFile 
)
static

The MakeRelativeName method creates a relative pathname of a child file as referenced by a parent file, such as a code file being referenced by a project file.

Parameters
parentFilecontains the full pathname of the parent file.
childFilecontains the full pathname of the child file.
Returns
The method returns the relative pathname required to reference the child file when in the parent location.

◆ ParseFileName()

static int gmslLibrary.Services.FileSystem.ParseFileName ( string  FileName,
ref int  LocalStart,
ref int  XtnStart 
)
static

The ParseFileName method parses a filename into its components. It views a filename as though it consisted of three concatenated components: path name, local name, and extension. This method computes the relative position within the full name of the start of the local name and the start of the extension. Since the path name is always first, if the local name start is greater than zero, then the beginning of the filename contains a path name.

Parameters
FileNamecontains the filename to be parsed.
LocalStartreturns 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.
XtnStartreturns the offset of the start of the extension in the filename. A value equal to the length of the filename indicates that the name had no extension.
Returns
The method returns the overall length of the filename.

The documentation for this class was generated from the following file: