Sourceforge.net - The VCF's Project Host
   The VCF Website Home   |   Online Discussion Forums   |   Sourceforge.net Project Page   

VCF::System Class Reference

The System object represents basic lower level OS functions. More...

#include <vcf/FoundationKit/System.h>

List of all members.

Public Types

enum  CommonDirectory {
  cdUserHome = 0, cdUserProgramData, cdUserDesktop, cdUserFavorites,
  cdUserDocuments, cdUserTemp, cdSystemPrograms, cdSystemTemp,
  cdSystemRoot
}
 This enum is used to represent various identifiers for common directories on the system. More...

Static Public Member Functions

static Systemcreate ()
 This is for internal usage only - don't call.
static void terminate ()
static String findResourceDirectory ()
 Locates the resource directory, if possible.
static String findResourceDirectory (Locale *locale)
 Finds the resource for the specific locale.
static String findResourceDirectory (const String &fileName, Locale *locale)
 This will find the resource directory using fileName as the starting point and the specified locale.
static String findResourceDirectoryForExecutable (const String &fileName)
static String getOSName ()
 Returns the name of the operating system that the VCF is currently running on.
static String getOSVersion ()
 Returns the version of the operating system.
static String getCompiler ()
 Returns the compiler that was used to build this version of the VCF.
static String getComputerName ()
 Returns the computer's name, assuming this is supported by the platform, otherwise an empty string.
static String getUserName ()
 Returns the current user name that the framework is being executed under.
static uint32 getTickCount ()
 Returns the current "tick" count.
static void sleep (const uint32 &milliseconds)
 Causes the calling thread/process to sleep for a specified number of milliseconds.
static void setErrorLog (ErrorLog *errorLog)
 sets the System's ErrorLog.
static void print (const String &text)
 Prints out the text to stdout.
static void println (const String &text)
 This function does what System::print() does, except that it adds a trailing cr/lf.
static void errorPrint (BasicException *exception)
 This will print the contents of the exception to stdout and the error log if it exists.
static bool doesFileExist (const String &fileName)
static String getEnvironmentVariable (const String &variableName)
 This will return the value of the specified environment variable.
static void setEnvironmentVariable (const String &variableName, const String &newValue)
 Modifies (or creates) an enviroment variable for the current process.
static void addPathDirectory (const String &directory)
 Adds a directory to the current process's PATH environment variable.
static String getCurrentWorkingDirectory ()
 Returns the current working directory.
static void setCurrentWorkingDirectory (const String &currentDirectory)
 Sets the current working directory.
static String getCommonDirectory (CommonDirectory directory)
 This returns the name of a standard directory for the OS.
static String createTempFileName (CommonDirectory directory)
 This creates a temp file name.
static String createTempFileName (const String &directory="")
 This creates a temp file name.
static void setDateToSystemTime (DateTime *date)
 Sets the date instance to the current system time (UTC based).
static void setDateToLocalTime (DateTime *date)
 Sets the date instance to the current local time.
static DateTime convertUTCTimeToLocalTime (const DateTime &date)
 This will convert a date in UTC to that of the system's local time zone, taking into account the system time zone, and DST if neccessary.
static DateTime convertLocalTimeToUTCTime (const DateTime &date)
 This will convert a date in the system's local time to UTC, taking into account the system time zone, and DST if neccessary.
static void setTimeZoneToLocal (const DateTime &currentDate, TimeZone &tz)
static void setCurrentThreadLocale (Locale *locale)
 Sets the current thread's locale.
static LocalegetCurrentThreadLocale ()
 Returns the current thread's locale.
static bool isUnicodeEnabled ()
 Is the system Unicode enabled, i.e.
static ResourceBundlegetResourceBundle ()
 Returns the ResourceBundle for the calling process.
static ProgramInfogetProgramInfoFromFileName (const String &fileName)
 Retrieves the program information from a given file name.
static ProgramInfogetProgramInfoFromInfoFile (const String &infoFileName)
 Returns a new ProgramInfo instance from a given info.xml or info.plist.
static ProgramInfogetProgramInfoFromInfoFile (const String &infoFileName, const String &programFileName)
 Returns a new ProgramInfo instance from a given info.xml or info.plist.
static String getBundlePathFromExecutableName (const String &fileName)
 Returns a string that is the package directory for the executable file name.
static String getExecutableNameFromBundlePath (const String &fileName)
 This attempts to return the complete path to the executable content in the bundle, as specified by the bundle program info.
static void internal_replaceResourceBundleInstance (ResourceBundle *newInstance)

Protected Member Functions

 System ()
virtual ~System ()

Static Protected Member Functions

static String getInfoFileFromFileName (const String &fileName)
static SystemgetInstance ()

Protected Attributes

SystemPeersystemPeer_
ErrorLogerrorLogInstance_
Localelocale_
ResourceBundleresBundle_

Static Protected Attributes

static SystemsystemInstance
static bool unicodeEnabled


Detailed Description

The System object represents basic lower level OS functions.

The System instance is a singleton, and may not be created or deleted directly. Instead the FunctionKit::init() and FoundationKit::terminate() take of this for you. You interact with it by calling the various static methods of the class, which in turn call the proper System peer implementation.


Member Enumeration Documentation

enum VCF::System::CommonDirectory
 

This enum is used to represent various identifiers for common directories on the system.

These each represent a valid file path, or an empty string if there is no such equivalent for the platform.

See also:
getCommonDirectory()
Enumerator:
cdUserHome  This is the home directory for the current user account that the framework is being executed from.
cdUserProgramData  This is the directory for storing application specific data for the current user account that the framework is being executed from.
cdUserDesktop  This is the directory that represents the desktop for the current user account that the framework is being executed from.
cdUserFavorites  This is the directory that represents where the user would store "favorites" (typically bookmarks, and the like) for the current user account that the framework is being executed from.
cdUserDocuments  This is the directory that represents where the user would store their documents (by default) for the current user account that the framework is being executed from.
cdUserTemp  This is the temp (or "scratch") directory for the current user account that the framework is being executed from.
cdSystemPrograms  This is the default, top level directory that the system stores programs/applications in.

On Win32 this generally "C:\Program Files\". On Mac OSX this would generally be "/Applications/".

cdSystemTemp  This is the system temp directory.
cdSystemRoot  This is the system root directory.


Constructor & Destructor Documentation

VCF::System::System  )  [protected]
 

virtual VCF::System::~System  )  [protected, virtual]
 


Member Function Documentation

static void VCF::System::addPathDirectory const String directory  )  [static]
 

Adds a directory to the current process's PATH environment variable.

If no such environment variable exists, then it does nothing. Note that some systems may not even have anything resembling a PATH.

static DateTime VCF::System::convertLocalTimeToUTCTime const DateTime date  )  [static]
 

This will convert a date in the system's local time to UTC, taking into account the system time zone, and DST if neccessary.

static DateTime VCF::System::convertUTCTimeToLocalTime const DateTime date  )  [static]
 

This will convert a date in UTC to that of the system's local time zone, taking into account the system time zone, and DST if neccessary.

static System* VCF::System::create  )  [static]
 

This is for internal usage only - don't call.

static String VCF::System::createTempFileName const String directory = ""  )  [static]
 

This creates a temp file name.

You can pass in directory name to indicate the directory to use in creating the file name. The directory is empty by default. For example to create just a temp file name (no directory) you might use:

static String VCF::System::createTempFileName CommonDirectory  directory  )  [static]
 

This creates a temp file name.

You can pass in a standard directory type to indicate the directory to use in creating the file name. For example to create a temp file in the user's temp directory you might use:

static bool VCF::System::doesFileExist const String fileName  )  [static]
 

static void VCF::System::errorPrint BasicException exception  )  [static]
 

This will print the contents of the exception to stdout and the error log if it exists.

static String VCF::System::findResourceDirectory const String fileName,
Locale locale
[static]
 

This will find the resource directory using fileName as the starting point and the specified locale.

static String VCF::System::findResourceDirectory Locale locale  )  [static]
 

Finds the resource for the specific locale.

The generic findResourceDirectory() assumes the locale that is currently set for the thread. The starting point is the programs executable path.

static String VCF::System::findResourceDirectory  )  [static]
 

Locates the resource directory, if possible.

Possible search patterns

A): Dead simple

    <app>.app/
        <app>.exe
        Resources/
            button.png          <-----generic files - not localized
            <app>.strings       <----- optional
            en_US/
                button.png      <-----localized files - localized for US english
                <app>.strings   <-----localized strings data for en_US
            pl_PL/
                button.png      <-----localized files - localized for Poland polish
                <app>.strings   <-----localized strings data for pl_PL
            it_IT/
                button.png      <-----localized files - localized for Italy italian
                <app>.strings   <-----localized strings data for it_IT

B): with contents - OSX compatible

    Bundle/
        /Contents
            <app>.exe
            Resources/
                button.png          <-----generic files - not localized
                <app>.strings       <----- optional
                en_US/
                    button.png      <-----localized files - localized for US english
                    <app>.strings   <-----localized strings data for en_US
                pl_PL/
                    button.png      <-----localized files - localized for Poland polish
                    <app>.strings   <-----localized strings data for pl_PL
                it_IT/
                    button.png      <-----localized files - localized for Italy italian
                    <app>.strings   <-----localized strings data for it_IT

C): with contents and platform - OSX compatible

    Bundle/
        /Contents
            /<OS-Name>
                <app>.exe
            Resources/
                button.png          <-----generic files - not localized
                <app>.strings       <----- optional
                en_US/
                    button.png      <-----localized files - localized for US english
                    <app>.strings   <-----localized strings data for en_US
                pl_PL/
                    button.png      <-----localized files - localized for Poland polish
                    <app>.strings   <-----localized strings data for pl_PL
                it_IT/
                    button.png      <-----localized files - localized for Italy italian
                    <app>.strings   <-----localized strings data for it_IT

D): with contents, platform, and compiler - OSX compatible

    Bundle/
        /Contents
            /<OS-Name>
                /<compiler>
                    <app>.exe
            Resources/
                button.png          <-----generic files - not localized
                <app>.strings       <----- optional
                en_US/
                    button.png      <-----localized files - localized for US english
                    <app>.strings   <-----localized strings data for en_US
                pl_PL/
                    button.png      <-----localized files - localized for Poland polish
                    <app>.strings   <-----localized strings data for pl_PL
                it_IT/
                    button.png      <-----localized files - localized for Italy italian
                    <app>.strings   <-----localized strings data for it_IT

static String VCF::System::findResourceDirectoryForExecutable const String fileName  )  [static]
 

static String VCF::System::getBundlePathFromExecutableName const String fileName  )  [static]
 

Returns a string that is the package directory for the executable file name.

If the file name is not a bundle, then an empty string is returned. For example, if passed in a file name such as "c:\Program Files\MyApp\Contents\WindowsNT\MyApp.exe", the function would return "c:\Program Files\MyApp\" as the result.

static String VCF::System::getCommonDirectory CommonDirectory  directory  )  [static]
 

This returns the name of a standard directory for the OS.

See also:
CommonDirectory

static String VCF::System::getCompiler  )  [static]
 

Returns the compiler that was used to build this version of the VCF.

This is a fixed, build setting that is platform and vendor dependant

Returns:
String the name of the compiler used to build the VCF. Can be:
  • "VC6" Microsoft Visual C++ 6
  • "VC7" Microsoft Visual C++ 7
  • "VC71" Microsoft Visual C++ 7.1
  • "DMC" Digital Mars
  • "GCC" GCC C++ compiler
  • "BCC4" Borland C++ compiler BCB4
  • "BCC5" Borland C++ compiler BCB5
  • "BCC6" Borland C++ compiler BCB6

static String VCF::System::getComputerName  )  [static]
 

Returns the computer's name, assuming this is supported by the platform, otherwise an empty string.

static Locale* VCF::System::getCurrentThreadLocale  )  [static]
 

Returns the current thread's locale.

This may be the same as the current user locale on systems that do not allow per thread locale settings (such as Mac OSX).

static String VCF::System::getCurrentWorkingDirectory  )  [static]
 

Returns the current working directory.

static String VCF::System::getEnvironmentVariable const String variableName  )  [static]
 

This will return the value of the specified environment variable.

For example, calling this on a Win32 system might return the following:

val would equal "C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;...".

static String VCF::System::getExecutableNameFromBundlePath const String fileName  )  [static]
 

This attempts to return the complete path to the executable content in the bundle, as specified by the bundle program info.

Attempts are made to drill down into succesively deeper directories, first the immediate bundle dir, then the Contents directory, then Contents/<OS-Name>, then Contents/<OS-Name>/<compiler>

static String VCF::System::getInfoFileFromFileName const String fileName  )  [static, protected]
 

static System* VCF::System::getInstance  )  [static, protected]
 

static String VCF::System::getOSName  )  [static]
 

Returns the name of the operating system that the VCF is currently running on.

Returns:
String the operating system name. Can be:
  • "MacOS" for Mac OS
  • "Linux" for linux based systems
  • "Solaris" for solaris systems
  • "Windows" for Win32 9.x based systems
  • "WindowsNT" for Win32 NT based systems
  • "WindowsCE" for WinCE based systems

static String VCF::System::getOSVersion  )  [static]
 

Returns the version of the operating system.

static ProgramInfo* VCF::System::getProgramInfoFromFileName const String fileName  )  [static]
 

Retrieves the program information from a given file name.

Parameters:
String the fully qualified file name of the process to retrieve information from, or a directory that includes a Info.plist/Info.xml file in it identifying the process's ProgramInfo.
See also:
ProgramInfo

ResourceBundle::getProgramInfo()

static ProgramInfo* VCF::System::getProgramInfoFromInfoFile const String infoFileName,
const String programFileName
[static]
 

Returns a new ProgramInfo instance from a given info.xml or info.plist.

If the infoFileName points to an invalid file, or there is some other problem reading the file, then the return value is NULL. The caller is responsible for deleting the ProgramInfo instance if a valid instance is returned.

Parameters:
String the full path of the info.plist/info.xml file
String the path of the initial value for the program file

static ProgramInfo* VCF::System::getProgramInfoFromInfoFile const String infoFileName  )  [static]
 

Returns a new ProgramInfo instance from a given info.xml or info.plist.

If the infoFileName points to an invalid file, or there is some other problem reading the file, then the return value is NULL. The caller is responsible for deleting the ProgramInfo instance if a valid instance is returned.

static ResourceBundle* VCF::System::getResourceBundle  )  [static]
 

Returns the ResourceBundle for the calling process.

Returns:
ResourceBundle* a pointer to the resource bundle. Do not delete this.

static uint32 VCF::System::getTickCount  )  [static]
 

Returns the current "tick" count.

On Win32 systems this is analagous to the GetTickCount() API. Should be millisecond resolution, but this is not by any means guaranteed.

static String VCF::System::getUserName  )  [static]
 

Returns the current user name that the framework is being executed under.

static void VCF::System::internal_replaceResourceBundleInstance ResourceBundle newInstance  )  [static]
 

static bool VCF::System::isUnicodeEnabled  )  [static]
 

Is the system Unicode enabled, i.e.

does it support the use of Unicode string in API calls. For example, if the VCF is running on a Win32 system on Windows 98 or Windows ME, this will return false. On a Win32 system that is NT based (Windows NT 4.0, Windows 2000, or Windows XP) this will return true. For Mac OSX this always returns true.

static void VCF::System::print const String text  )  [static]
 

Prints out the text to stdout.

Allows for formatted text, just like printf() does. Please see printf documentation for the various formatting flags.

When using this to print out strings, there are some special rules to fullow due to the fact that the VCF uses all unicode strings internally. For example:

    String aName = "Bob Jones";
    System::print( Format("User Name: %s") % aName.c_str() );
On Win32 platforms the use of s will work fine, but on others it may not. To ensure that strings get printed out correctly, consider using the ls formatter, like so:
    String aName = "Bob Jones";
    System::print( Format("User Name: %ls") % aName.c_str() );
or

    String aName = "Bob Jones";
    System::print( Format("User Name: %s") % aName );

This will ensure that on all platforms the unicode string gets properly handled and output.

See also:
Format

static void VCF::System::println const String text  )  [static]
 

This function does what System::print() does, except that it adds a trailing cr/lf.

See also:
System::print

static void VCF::System::setCurrentThreadLocale Locale locale  )  [static]
 

Sets the current thread's locale.

May not have an impact on some systems.

static void VCF::System::setCurrentWorkingDirectory const String currentDirectory  )  [static]
 

Sets the current working directory.

static void VCF::System::setDateToLocalTime DateTime date  )  [static]
 

Sets the date instance to the current local time.

This may be different from the result of calling System::setDateToSystemTime().

static void VCF::System::setDateToSystemTime DateTime date  )  [static]
 

Sets the date instance to the current system time (UTC based).

static void VCF::System::setEnvironmentVariable const String variableName,
const String newValue
[static]
 

Modifies (or creates) an enviroment variable for the current process.

This modification is only good for the lifetime of the process.

static void VCF::System::setErrorLog ErrorLog errorLog  )  [static]
 

sets the System's ErrorLog.

Note the Errolog is NOT owned by the System, so it is the caller's responsibility to clean up the memory. The suggested use is to create an ErrorLog object on the stack in your main() function and then pass it to the System after initialization of the FoundationKit is done (i.e. after initFoundationKit() )

static void VCF::System::setTimeZoneToLocal const DateTime currentDate,
TimeZone tz
[static]
 

static void VCF::System::sleep const uint32 milliseconds  )  [static]
 

Causes the calling thread/process to sleep for a specified number of milliseconds.

static void VCF::System::terminate  )  [static]
 


Member Data Documentation

ErrorLog* VCF::System::errorLogInstance_ [protected]
 

Locale* VCF::System::locale_ [protected]
 

ResourceBundle* VCF::System::resBundle_ [protected]
 

System* VCF::System::systemInstance [static, protected]
 

SystemPeer* VCF::System::systemPeer_ [protected]
 

bool VCF::System::unicodeEnabled [static, protected]
 


The documentation for this class was generated from the following file:
   Comments or Suggestions?    License Information