ADTF
cSystem

System or platform specific functions. More...

Classes

class  cAdapterInfo
 Helper class to store ethernet adapter infos, see cSystem::GetEthernetAdapterInfo. More...
 
class  IAdapterInfoCallback
 Callback for cSystem::GetEthernetAdapterInfo() More...
 

Static Public Member Functions

static tUInt32 GetLastSystemError ()
 Returns the last system error. More...
 
static cString GetLastErrorString (const tUInt32 ui32Error)
 Returns a descriptive string of the last error. More...
 
static cString GetEnvVariable (const cString &strName, const cString &strDefaultValue="")
 This function fetches values from the system's environment configuration. More...
 
static tResult SetEnvVariable (const cString &strName, const cString &strValue)
 This function creates a system's environment variable for the current execution. More...
 
static cString GetUserName ()
 This function gets the user name currently logged on. More...
 
static cString GetComputerName ()
 This function gets the name of the local computer. More...
 
static tInt32 Execute (const cFilename &strExeFile, const cString &strArgs="", const cFilename &strWorkingPath="", const tBool bModal=tFalse, cString *pOutput=nullptr, const cFilename oStdErrForward="")
 Starts an executable and optionally wait for the application to close down. More...
 
static tResult ChildExecute (tUInt64 *pChildProcessId, const cFilename &strExeFile, const cString &strArgs="")
 Starts a child process. More...
 
static tResult ChildWait (tUInt64 nChildProcessId, tTimeStamp tmTimeOut=-1)
 Wait until a child process exits. More...
 
static tResult ChildTerminate (tUInt64 nChildProcessId)
 Terminates a child process. More...
 
static tUInt32 OpenDocument (tHandle hWndParent, const cFilename &strFilename, const cString &strWorkingPath="", tBool bModal=tFalse, tBool bMessage=tFalse)
 Opens a document with the registered standard application. More...
 
static tUInt32 OpenFolder (tHandle hWndParent, const cFilename &strFilename, tHandle &hProcessHandle, tBool bModal=tFalse)
 Opens an Explorer window that points to the specified folder. More...
 
static tTimeStamp GetTime ()
 On Windows platform method will return elapsed time in microseconds since the system was started. More...
 
static tVoid Sleep (tTimeStamp tmMicroseconds)
 The calling thread will sleep for the specified amount of time. More...
 
static tResult GetMACAddress (cString &strMACAddress)
 Returns the MAC Address of the first networking interface. More...
 
static tInt GetProcessorCount ()
 Returns the count of processors. More...
 
static tInt32 GetCurrentThreadId ()
 Returns the current thread id. More...
 
static tUInt64 GetCurrentProcessId ()
 Returns the current process id. More...
 
static tUInt64 GetVirtualUserMemoryTotal ()
 Returns the total amount of virtual memory for User-mode applications. More...
 
static tUInt64 GetVirtualUserMemoryUsed ()
 Returns the amount of virtual user memory currently used (process) More...
 
static tUInt64 GetVirtualMemoryTotal ()
 Returns the total amount of virtual memory. More...
 
static tUInt64 GetVirtualMemoryUsed ()
 Returns the amount of virtual memory currently used (system global) More...
 
static tUInt64 GetVirtualMemoryUsedByMe ()
 Returns the amount of virtual memory currently used by the calling process. More...
 
static tUInt64 GetPhysicalMemoryTotal ()
 Returns the total amount of physical memory. More...
 
static tUInt64 GetPhysicalMemoryUsed (tBool bIncludeCaches=tFalse)
 Returns the amount of physical memory currently used (system global) More...
 
static tUInt64 GetPhysicalMemoryUsedByMe ()
 Returns the amount of physical memory currently used by the calling process. More...
 
static tResult GetMallocInfo (tUInt64 &nMallocTotal, tUInt64 &nMallocFree, tUInt64 &nMallocUsed)
 Returns information about the status of malloc memory handling. More...
 
static tResult HasIfaceWithMAC (const cString &strMACAddress)
 Checks whether he host as an interface with a specific MAC address. More...
 
static tBool QueryDriveSpace (const cString &strDriveLetter, tUInt64 &uint64FreeSize)
 This Function retrieves the free disk space in bytes for the specified location (win32). More...
 
static tResult SwapEndian (tUInt8 *pui8Value)
 Swaps the bytes of a 8 Bit value in place. More...
 
static tResult SwapEndian (tInt8 *pi8Value)
 Swaps the bytes of a 8 Bit value in place. More...
 
static tResult SwapEndian (tUInt16 *pui16Value)
 Swaps the bytes of a 16 Bit value in place. More...
 
static tResult SwapEndian (tInt16 *pi16Value)
 Swaps the bytes of a 16 Bit value in place. More...
 
static tResult SwapEndian (tUInt32 *pui32Value)
 Swaps the bytes of a 32 Bit value in place. More...
 
static tResult SwapEndian (tInt32 *pi32Value)
 Swaps the bytes of a 32 Bit value in place. More...
 
static tResult SwapEndian (tUInt64 *pui64Value)
 Swaps the bytes of a 64 Bit value in place. More...
 
static tResult SwapEndian (tInt64 *pi64Value)
 Swaps the bytes of a 64 Bit value in place. More...
 
static tResult HostToNetwork (tUInt16 *pui16Value)
 Swaps the bytes of a 16 Bit value from host to network byte order. More...
 
static tResult HostToNetwork (tUInt32 *pui32Value)
 Swaps the bytes of a 32 Bit value from host to network byte order. More...
 
static tResult HostToNetwork (tUInt64 *pui64Value)
 Swaps the bytes of a 64 Bit value from host to network byte order. More...
 
static tResult NetworkToHost (tUInt16 *pui16Value)
 Swaps the bytes of a 16 Bit value from network to host byte order. More...
 
static tResult NetworkToHost (tUInt32 *pui32Value)
 Swaps the bytes of a 32 Bit value from network to host byte order. More...
 
static tResult NetworkToHost (tUInt64 *pui64Value)
 Swaps the bytes of a 64 Bit value from network to host byte order. More...
 
static tResult SendMail (const cString &strOriginator, const cString &strOriginatorName, const cString &strRecipient, const cString &strRecipientName, const cString &strSubject, const cString &strText, const cString &strFilePath)
 Sends an email (win32). More...
 
static tResult GetEthernetAdapterInfo (IAdapterInfoCallback *pAdapterInfo)
 Returns all detected ethernet adapters. More...
 

Detailed Description

Member Function Documentation

◆ ChildExecute()

static tResult ChildExecute ( tUInt64 pChildProcessId,
const cFilename strExeFile,
const cString strArgs = "" 
)
static

Starts a child process.

Parameters
[out]pChildProcessIdThe process id of the child process.
[in]strExeFileThe executable that should be launched.
[in]strArgsAddidional arguments.
Returns
ERR_UNEXPECTED if something goes wrong, see GetLastSystemError().

◆ ChildTerminate()

static tResult ChildTerminate ( tUInt64  nChildProcessId)
static

Terminates a child process.

Parameters
[in]nChildProcessIdThe process id of the child process.
Returns
ERR_UNKNOWN when something goes wrong, see GetLastSystemError().

◆ ChildWait()

static tResult ChildWait ( tUInt64  nChildProcessId,
tTimeStamp  tmTimeOut = -1 
)
static

Wait until a child process exits.

Note that after the process has exited, this method can only be called once.

Parameters
[in]nChildProcessIdThe process id of the child process.
[in]tmTimeOutTimeout in microseconds: -1 -> no timeout, 0 -> return immediately.
Returns
ERR_TIMEOUT when the process has not exited.

◆ Execute()

static tInt32 Execute ( const cFilename strExeFile,
const cString strArgs = "",
const cFilename strWorkingPath = "",
const tBool  bModal = tFalse,
cString pOutput = nullptr,
const cFilename  oStdErrForward = "" 
)
static

Starts an executable and optionally wait for the application to close down.

Parameters
strExeFile[in] Path to executable.
strArgs[in] Arguments to be passed to the executable.
strWorkingPath[in] Working path. If empty uses current working directory.
bModal[in] Bool that specifies if the function should wait for the application to close down.
pOutput[out] Optional: all output to stdout will be stored here.
oStdErrForward[in] This option will Forward the stderr to the given file (if set to "&1" it is forwarded to pOutput)
Returns
This function returns the exit code of the application. If the modal flag is set to tFalse , the function returns 0;

◆ GetComputerName()

static cString GetComputerName ( )
static

This function gets the name of the local computer.

Returns
computer name

◆ GetCurrentProcessId()

static tUInt64 GetCurrentProcessId ( )
static

Returns the current process id.

Returns
Id of the current process

◆ GetCurrentThreadId()

static tInt32 GetCurrentThreadId ( )
static

Returns the current thread id.

Returns
Id of the current thread

◆ GetEnvVariable()

static cString GetEnvVariable ( const cString strName,
const cString strDefaultValue = "" 
)
static

This function fetches values from the system's environment configuration.

Parameters
strName[in] Name of environment variable to be fetched.
strDefaultValue[in] Value that is returned if the environment variable doesn't exist.
Returns
The function creates a new cString object that is initialized with the environment value.

◆ GetEthernetAdapterInfo()

static tResult GetEthernetAdapterInfo ( IAdapterInfoCallback pAdapterInfo)
static

Returns all detected ethernet adapters.

Parameters
[in,out]pAdapterInfoCallback for retrieval of all adapter information.
Returns
Standard result.

◆ GetLastErrorString()

static cString GetLastErrorString ( const tUInt32  ui32Error)
static

Returns a descriptive string of the last error.

Parameters
ui32Error[in] An error code to be translated
Returns
The error string.

◆ GetLastSystemError()

static tUInt32 GetLastSystemError ( )
static

Returns the last system error.

Returns
The last system error in windows and errno in linux

◆ GetMACAddress()

static tResult GetMACAddress ( cString strMACAddress)
static

Returns the MAC Address of the first networking interface.

Parameters
strMACAddress[out] The destination string.
Returns
Standard result.

◆ GetMallocInfo()

static tResult GetMallocInfo ( tUInt64 nMallocTotal,
tUInt64 nMallocFree,
tUInt64 nMallocUsed 
)
static

Returns information about the status of malloc memory handling.

Parameters
[out]nMallocTotalThe total amount of memory requested from the OS.
[out]nMallocFreeThe unused portion of the requested memory.
[out]nMallocUsedThe used portion of the requested memory, this number tells how much memory your program uses.
Returns
Standard result.

◆ GetPhysicalMemoryTotal()

static tUInt64 GetPhysicalMemoryTotal ( )
static

Returns the total amount of physical memory.

Returns
number of bytes of physical memory total

◆ GetPhysicalMemoryUsed()

static tUInt64 GetPhysicalMemoryUsed ( tBool  bIncludeCaches = tFalse)
static

Returns the amount of physical memory currently used (system global)

Parameters
[in]bIncludeCachesWhether or not to include system caches and buffers into the calculation (This has no effect on Windows).
Returns
number of bytes of physical memory used

◆ GetPhysicalMemoryUsedByMe()

static tUInt64 GetPhysicalMemoryUsedByMe ( )
static

Returns the amount of physical memory currently used by the calling process.

Returns
number of bytes of physical memory used by current process

◆ GetProcessorCount()

static tInt GetProcessorCount ( )
static

Returns the count of processors.

Returns
Count of processors will be a positive number > 0
Remarks
This method will never fail and the return value will not change during runtime.

◆ GetTime()

static tTimeStamp GetTime ( )
static

On Windows platform method will return elapsed time in microseconds since the system was started.

On Linux platform method will return time in microseconds since some unspecified starting point.

Returns
The time in microseconds.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ GetUserName()

static cString GetUserName ( )
static

This function gets the user name currently logged on.

Returns
user name

◆ GetVirtualMemoryTotal()

static tUInt64 GetVirtualMemoryTotal ( )
static

Returns the total amount of virtual memory.

Returns
number of bytes of virtual memory total

◆ GetVirtualMemoryUsed()

static tUInt64 GetVirtualMemoryUsed ( )
static

Returns the amount of virtual memory currently used (system global)

Returns
number of bytes of virtual memory used

◆ GetVirtualMemoryUsedByMe()

static tUInt64 GetVirtualMemoryUsedByMe ( )
static

Returns the amount of virtual memory currently used by the calling process.

Returns
number of bytes of virtual memory used by current process

◆ GetVirtualUserMemoryTotal()

static tUInt64 GetVirtualUserMemoryTotal ( )
static

Returns the total amount of virtual memory for User-mode applications.

Returns
number of bytes of virtual user memory total

◆ GetVirtualUserMemoryUsed()

static tUInt64 GetVirtualUserMemoryUsed ( )
static

Returns the amount of virtual user memory currently used (process)

Returns
number of bytes of virtual user memory used

◆ HasIfaceWithMAC()

static tResult HasIfaceWithMAC ( const cString strMACAddress)
static

Checks whether he host as an interface with a specific MAC address.

Parameters
strMACAddress[in] The MAC address
Returns
Standard result.

◆ HostToNetwork() [1/3]

static tResult HostToNetwork ( tUInt16 pui16Value)
static

Swaps the bytes of a 16 Bit value from host to network byte order.

Parameters
pui16Value[inout] The value.
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ HostToNetwork() [2/3]

static tResult HostToNetwork ( tUInt32 pui32Value)
static

Swaps the bytes of a 32 Bit value from host to network byte order.

Parameters
pui32Value[inout] The value.
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ HostToNetwork() [3/3]

static tResult HostToNetwork ( tUInt64 pui64Value)
static

Swaps the bytes of a 64 Bit value from host to network byte order.

Parameters
pui64Value[inout] The value.
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ NetworkToHost() [1/3]

static tResult NetworkToHost ( tUInt16 pui16Value)
static

Swaps the bytes of a 16 Bit value from network to host byte order.

Parameters
pui16Value[inout] The value.
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ NetworkToHost() [2/3]

static tResult NetworkToHost ( tUInt32 pui32Value)
static

Swaps the bytes of a 32 Bit value from network to host byte order.

Parameters
pui32Value[inout] The value.
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ NetworkToHost() [3/3]

static tResult NetworkToHost ( tUInt64 pui64Value)
static

Swaps the bytes of a 64 Bit value from network to host byte order.

Parameters
pui64Value[inout] The value.
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ OpenDocument()

static tUInt32 OpenDocument ( tHandle  hWndParent,
const cFilename strFilename,
const cString strWorkingPath = "",
tBool  bModal = tFalse,
tBool  bMessage = tFalse 
)
static

Opens a document with the registered standard application.

REMARK: On Linux this command will call "kfmclient", "gnome-open", "gvfs-open" or "xdg-open" with the document name. Make sure one of these programs is installed on the system to make cSystem::OpenDocument work.

Parameters
hWndParent[in] Parent window for application (win32). Can be nullptr.
strFilename[in] Path to document.
strWorkingPath[in] Working path.
bModal[in] Bool that specifies if the function should wait for the application to close down.
bMessage[in] If true messages will be displayed
Returns
This function returns the exit code of the application. If the modal flag is set, the function returns 0;

◆ OpenFolder()

static tUInt32 OpenFolder ( tHandle  hWndParent,
const cFilename strFilename,
tHandle hProcessHandle,
tBool  bModal = tFalse 
)
static

Opens an Explorer window that points to the specified folder.

This works only on windows. With Linux this method has no functionality and returns always with 0xFFFFFFFF

Parameters
hWndParent[in] Parent window for Exporer.
strFilename[in] Path to folder.
hProcessHandle[out] Process handle.
bModal[in] if true then the new window will be opened modal
Returns
returns the exit code of the dialog.

◆ QueryDriveSpace()

static tBool QueryDriveSpace ( const cString strDriveLetter,
tUInt64 uint64FreeSize 
)
static

This Function retrieves the free disk space in bytes for the specified location (win32).

There is no functionality with linux and returns always with tFalse

Parameters
strDriveLetter[in] Specifies the root directory of the disk. A trailing backslash is required.
uint64FreeSize[out] free bytes
Returns
const tBool -> tTrue: successful

◆ SendMail()

static tResult SendMail ( const cString strOriginator,
const cString strOriginatorName,
const cString strRecipient,
const cString strRecipientName,
const cString strSubject,
const cString strText,
const cString strFilePath 
)
static

Sends an email (win32).

Under Linux this method has no functionality and returns always with ERR_NOT_SUPPORTED

Parameters
strOriginator[in] The senders mail address.
strOriginatorName[in] The senders name.
strRecipient[in] The recipients mali address.
strRecipientName[in] The recipients name.
strSubject[in] The subject of the message.
strText[in] The message content.
strFilePath[in] An attachment file.
Returns
Standard result.

◆ SetEnvVariable()

static tResult SetEnvVariable ( const cString strName,
const cString strValue 
)
static

This function creates a system's environment variable for the current execution.

Parameters
[in]strNameName of environment variable to set.
[in]strValueValue to set.
Returns
The Standard Result Code.

◆ Sleep()

static tVoid Sleep ( tTimeStamp  tmMicroseconds)
static

The calling thread will sleep for the specified amount of time.

Parameters
tmMicroseconds[in] The time to sleep in microsenconds.
Returns
void

◆ SwapEndian() [1/8]

static tResult SwapEndian ( tInt16 pi16Value)
static

Swaps the bytes of a 16 Bit value in place.

Parameters
pi16Value[inout] The value.
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ SwapEndian() [2/8]

static tResult SwapEndian ( tInt32 pi32Value)
static

Swaps the bytes of a 32 Bit value in place.

Parameters
pi32Value[inout] The value.
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ SwapEndian() [3/8]

static tResult SwapEndian ( tInt64 pi64Value)
static

Swaps the bytes of a 64 Bit value in place.

Parameters
pi64Value[inout] The value.
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ SwapEndian() [4/8]

static tResult SwapEndian ( tInt8 pi8Value)
static

Swaps the bytes of a 8 Bit value in place.

Parameters
pi8Value[inout] The value.
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ SwapEndian() [5/8]

static tResult SwapEndian ( tUInt16 pui16Value)
static

Swaps the bytes of a 16 Bit value in place.

Parameters
pui16Value[inout] The value.
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ SwapEndian() [6/8]

static tResult SwapEndian ( tUInt32 pui32Value)
static

Swaps the bytes of a 32 Bit value in place.

Parameters
pui32Value[inout] The value.
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ SwapEndian() [7/8]

static tResult SwapEndian ( tUInt64 pui64Value)
static

Swaps the bytes of a 64 Bit value in place.

Parameters
pui64Value[inout] The value.
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ SwapEndian() [8/8]

static tResult SwapEndian ( tUInt8 pui8Value)
static

Swaps the bytes of a 8 Bit value in place.

Parameters
pui8Value[inout] The value.
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n