VCF::System Class Reference
The System object represents basic lower level OS functions. More...
#include <vcf/FoundationKit/System.h>
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 System * | create () |
| 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 ¤tDirectory) |
| 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 ¤tDate, TimeZone &tz) |
| static void | setCurrentThreadLocale (Locale *locale) |
| Sets the current thread's locale. | |
| static Locale * | getCurrentThreadLocale () |
| Returns the current thread's locale. | |
| static bool | isUnicodeEnabled () |
| Is the system Unicode enabled, i.e. | |
| static ResourceBundle * | getResourceBundle () |
| Returns the ResourceBundle for the calling process. | |
| static ProgramInfo * | getProgramInfoFromFileName (const String &fileName) |
| Retrieves the program information from a given file name. | |
| static ProgramInfo * | getProgramInfoFromInfoFile (const String &infoFileName) |
| Returns a new ProgramInfo instance from a given info.xml or info.plist. | |
| static ProgramInfo * | getProgramInfoFromInfoFile (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 System * | getInstance () |
Protected Attributes | |
| SystemPeer * | systemPeer_ |
| ErrorLog * | errorLogInstance_ |
| Locale * | locale_ |
| ResourceBundle * | resBundle_ |
Static Protected Attributes | |
| static System * | systemInstance |
| 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
|
|
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.
|
Constructor & Destructor Documentation
|
|
|
|
|
|
Member Function Documentation
|
|
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. |
|
|
This will convert a date in the system's local time to UTC, taking into account the system time zone, and DST if neccessary.
|
|
|
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.
|
|
|
This is for internal usage only - don't call.
|
|
|
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: String tempFile = System::createTempFileName(); |
|
|
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: String tempFile = System::createTempFileName( System::cdUserTemp ); |
|
|
|
|
|
This will print the contents of the exception to stdout and the error log if it exists.
|
|
||||||||||||
|
This will find the resource directory using fileName as the starting point and the specified locale.
|
|
|
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. |
|
|
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
|
|
|
|
|
|
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. |
|
|
This returns the name of a standard directory for the OS.
|
|
|
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 the computer's name, assuming this is supported by the platform, otherwise an empty string.
|
|
|
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). |
|
|
Returns the current working directory.
|
|
|
This will return the value of the specified environment variable. For example, calling this on a Win32 system might return the following: String val = System::getEnvironmentVariable( "PATH" ); |
|
|
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> |
|
|
|
|
|
|
|
|
Returns the name of the operating system that the VCF is currently running on.
|
|
|
Returns the version of the operating system.
|
|
|
Retrieves the program information from a given file name.
|
|
||||||||||||
|
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.
|
|
|
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. |
|
|
Returns the ResourceBundle for the calling process.
|
|
|
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. |
|
|
Returns the current user name that the framework is being executed under.
|
|
|
|
|
|
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. |
|
|
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() ); String aName = "Bob Jones"; System::print( Format("User Name: %ls") % aName.c_str() );
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.
|
|
|
This function does what System::print() does, except that it adds a trailing cr/lf.
|
|
|
Sets the current thread's locale. May not have an impact on some systems. |
|
|
Sets the current working directory.
|
|
|
Sets the date instance to the current local time. This may be different from the result of calling System::setDateToSystemTime(). |
|
|
Sets the date instance to the current system time (UTC based).
|
|
||||||||||||
|
Modifies (or creates) an enviroment variable for the current process. This modification is only good for the lifetime of the process. |
|
|
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() ) |
|
||||||||||||
|
|
|
|
Causes the calling thread/process to sleep for a specified number of milliseconds.
|
|
|
|
Member Data Documentation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The documentation for this class was generated from the following file:
- vcf/FoundationKit/System.h
