MPIO v1.6.0
Multi-platform common IO library
Loading...
Searching...
No Matches
os.h File Reference

Common operating system functions. More...

#include <stdint.h>
#include <stdarg.h>
#include <stdbool.h>

Functions

double getCurrentClock ()
 Returns high resolution time stamp in seconds. (MT-Safe).
int getLogicalCpuCount ()
 Returns system logical CPU count. (MT-Safe).
int getPhysicalCpuCount ()
 Returns system physical CPU count. (MT-Safe).
int getPerformanceCpuCount ()
 Returns system performance CPU count. (MT-Safe).
int64_t getTotalRamSize ()
 Returns system total physical RAM size. (MT-Safe).
int64_t getFreeRamSize ()
 Returns system free physical RAM size. (MT-Safe).
char * getCpuName ()
 Returns system CPU name string. (MT-Safe).
int executeFileA (const char *filePath, char **args)
 Executes specified file with arguments. (MT-Safe).
int executeFileVA (const char *filePath, va_list args)
 Executes specified file with arguments. (MT-Safe).
int executeFile (const char *filePath,...)
 Executes specified file with arguments. (MT-Safe).
bool openFileManager (const char *path)
 Opens file using preferred application. (Explorer, Finder, Browser, etc.).
void showError (const char *title, const char *message)
 Shows system error message. (Window or popup).

Detailed Description

Common operating system functions.

Function Documentation

◆ getCurrentClock()

double getCurrentClock ( )

Returns high resolution time stamp in seconds. (MT-Safe).

That can be used for time-interval measurements.

Returns
The time since some unspecified starting point.

◆ getLogicalCpuCount()

int getLogicalCpuCount ( )

Returns system logical CPU count. (MT-Safe).

Useful for a background thread pool thread count.

◆ getPhysicalCpuCount()

int getPhysicalCpuCount ( )

Returns system physical CPU count. (MT-Safe).

Useful for a foreground thread pool thread count.

◆ getPerformanceCpuCount()

int getPerformanceCpuCount ( )

Returns system performance CPU count. (MT-Safe).

Usefull for a foreground thread pool thread count.

◆ getTotalRamSize()

int64_t getTotalRamSize ( )

Returns system total physical RAM size. (MT-Safe).

Usefull for an OS information logging.

Returns
The total RAM size in bytes on success, otherwise -1.

◆ getFreeRamSize()

int64_t getFreeRamSize ( )

Returns system free physical RAM size. (MT-Safe).

Usefull for an OS information logging.

Returns
The free RAM size in bytes on success, otherwise -1.

◆ getCpuName()

char * getCpuName ( )

Returns system CPU name string. (MT-Safe).

Usefull for an OS information logging.

Note
You should free() the allocated string manually.
Returns
An allocated CPU name string.

◆ executeFileA()

int executeFileA ( const char * filePath,
char ** args )

Executes specified file with arguments. (MT-Safe).

Safe std::system() function alternative with arguments.

Returns
Program exit code or -1 if process stopped or crashed.
Parameters
[in]filePathfile path string
[in]argsprogram arguments (last should be NULL!)

◆ executeFileVA()

int executeFileVA ( const char * filePath,
va_list args )

Executes specified file with arguments. (MT-Safe).

Safe std::system() function alternative with arguments.

Returns
Program exit code or -1 if process stopped or crashed.
Parameters
[in]filePathfile path string
argsprogram arguments

◆ executeFile()

int executeFile ( const char * filePath,
... )

Executes specified file with arguments. (MT-Safe).

Safe std::system() function alternative with arguments.

Warning
Always pass NULL as the last argument in the list!!!
Returns
Program exit code or -1 if process stopped or crashed.
Parameters
[in]filePathfile path string
...program arguments

◆ openFileManager()

bool openFileManager ( const char * path)

Opens file using preferred application. (Explorer, Finder, Browser, etc.).

Parameters
[in]pathdirectory or file path string
Returns
True on success, otherwise false.

◆ showError()

void showError ( const char * title,
const char * message )

Shows system error message. (Window or popup).

Parameters
[in]titlemessage title string
[in]messageerror message string