Page tree
Skip to end of metadata
Go to start of metadata

The OperationgSystem Service Class

The service class OperatingSystem performs those operations that require direct access to the operating system that cannot implemented in a platform independent way. This implementation is provided for Windows platforms MSCPLAT. Other platforms would require their own version.

The method OperatingSystem_CopyFile

Prototype


int OperatingSystem_CopyFile(char* SrcFile, char* DestFile);
The OperatingSystem_CopyFile method does a file copy in as efficient a method as possible. If the destination file already exists, it will be overridden. Its parameters are as follows:

Parameter Description
SrcFile Contains the name of the source file in null-terminated string form.
DestFile Contains the name of the destination file in null-terminated form.

If the copy succeeds, the return value is nonzero, else the return value is zero.

The method OperatingSystem_DeleteDirectory

Prototype


int OperatingSystem_DeleteDirectory(char* Directory);
The OperatingSystem_DeleteDirectory method deletes a named directory. Its parameter is:

Parameter Description
Directory Contains the name of the directory to be deleted in null-terminated string form.

If the directory is successfully deleted, then a zero is returned. If the directory cannot be deleted, then a one is returned.

The method OperatingSystem_GetGuid

Prototype


int OperatingSystem_GetGuid(char* guidStr,int length);
The OperatingSystem_GetGuid method returns a created GUID string. A GUID is a Globally Unique Identifier, a unique 128-bit number that is used to identify a particular component, application, file, database entry, or user. This method uses the operating to create such an identifier in the commonly used string form. Each call to this method creates a new unique GUID. Its parameters are as follows:

Parameter Description
guidStr Receives the GUID as obtained from the operating system. It is not null-terminated.
length Specifies the length of guidStr. It is used to avoid overflow. No more than length characters will be copied into it.

The method returns the length of the GUID string as returned.

The method OperatingSystem_GetFileInfo

Prototype


int OperatingSystem_GetFileInfo(char* Filename,tOperatingSystem_FileInfo* FileInfo);
The method OperatingSystem_GetFileInfo gets information about a specific file from the operating system. This information is as follows:

Member Description
FileName Full name of file
Extension Extension associated with file
LocalStart Start of local name
TypeOfFile The type of the file
DateModified Date last modified
TimeModified Time last modified
DateCreated Date created
TimeCreated Time created
DateAccessed Date last accessed
TimeAccessed Time last accessed
CurrentSize Current size of file
Protection Protection status
Mode Mode of file

The parameters of the method are as follows:

Parameter Description
Filename Contains the name of the file in null-terminated form.
Fileinfo Receives the information about the file as listed above.


The method OperatingSystem_GetLibraryMethod

Prototype


MethodHandle OperatingSystem_GetLibraryMethod(void* library,CONST char* methodName);
The OperatingSystem_GetLibraryMethod method gets the execution handle to a method in a loaded a dynamic link library. Its parameters are as follows:

Parameter Description
library Specifies the handle of the library containing the desired method obtained from the method OperatingSystem_LoadLibrary.
methodName Contains the name of the method to be executed in null-terminated form.

This method returns an execution handle to the method if all went well; else it returns a NULL.

The method OperatingSystem_GetTime

Prototype


int OperatingSystem_GetTime(void);
The OperatingSystem_GetTime method returns the current time in milliseconds. It has no parameters.

The method OperatingSystem_GetProgramName

Prototype


void OperatingSystem_GetProgramName(char* name,int nName)
The OperatingSystem_GetProgramName method obtains the name of the currently executing program. This name is typically used to determine the names of corresponding startup files. Its parameters are as follows:

Parameter Description
name Receives the name of the executing program in null-terminated form.
nName Specifies the size of the name return area and is used to avoid overflow.


The method OperatingSystem_LoadLibrary

Prototype


void* OperatingSystem_LoadLibrary(char* libName);
The OperatingSystem_LoadLibrary method loads a dynamic link library and returns the handle to its information. Its parameter is:

Parameter Description
libName Contains the name of the library to be loaded in null-terminated string form.

This method returns an opaque handle to the loaded library information if all went well; else it returns a NULL.

The method OperatingSystem_MakeDirectory

Prototype


int OperatingSystem_MakeDirectory(char* Directory);
The OperatingSystem_MakeDirectory method makes a directory in the file system. Its parameter is:

Parameter Description
Directory Contains the name of the directory to be created as a null-terminated string.

If the directory is successfully created, then a zero is returned. If the directory cannot be created, then a one is returned.

The method OperatingSystem_ReadFileDirectory

Prototype


int OperatingSystem_ReadFileDirectory(char* DirName,tOperatingSystem_FileInfo* FileInfo);
The OperatingSystem_ReadFileDirectory method reads the file directory one entry at a time. It is used to obtain a listing of all files in a directory. The information about each file is stored in a tOperatingSystem_FileInfo structure whose members are as follows:

Member Description
FileName Full name of file
Extension Extension associated with file
LocalStart Start of local name
TypeOfFile The type of the file
DateModified Date last modified
TimeModified Time last modified
DateCreated Date created
TimeCreated Time created
DateAccessed Date last accessed
TimeAccessed Time last accessed
CurrentSize Current size of file
Protection Protection status
Mode Mode of file
InternalInfo Used internally

The parameters of the method are as follows:

Parameter Description
DirName Contains the name of the directory to be read on the initial call to this method. On subsequent calls this parameter is set to NULL.
FileInfo Receives the tOperatingSystem_FileInfo member values for the current file.

If information about a first or next file is being returned, then a zero is returned. If no more files are present, a one is returned.

The method OperatingSystem_UnloadLibrary

Prototype


void OperatingSystem_UnloadLibrary(void* library);
The OperatingSystem_UnloadLibrary method unloads a dynamic link library. Its parameter is:

Parameter Description
library Specifies the handle of the library to be unloaded as received from the method OperatingSystem_LoadLibrary.


Table of Contents

  • No labels