Gorgon Game Engine
Gorgon::OS Namespace Reference

This namespace contains operating system related functionality. More...

Namespaces

 User
 Contains user related information and services.
 

Classes

struct  Info
 This structure represents the version of the operating system. More...
 

Functions

void DisplayMessage (const std::string &message)
 This function shows a OS message box to display errors, for other messages its better to use in-game dialogs. More...
 
std::string GetAppDataPath ()
 Returns the directory where the system wide application data is stored. More...
 
std::string GetAppSettingPath ()
 Returns the directory where the system wide application settings is stored. More...
 
std::string GetEnvVar (const std::string &var)
 Returns the value of an environment variable. More...
 
Info GetInfo ()
 Returns information related with the operating system, including version, name, and architecture. More...
 
std::string GetName ()
 Returns the name of the current operating system in human readable form. More...
 
void Initialize ()
 Initializes operating system module. More...
 
bool Open (const std::string &file)
 Opens the given file with the related application. More...
 
void OpenTerminal ()
 Opens a terminal window to display output from the stdout. More...
 
void processmessages ()
 This method will notify the system should process any messages that coming from the operating system. More...
 
bool Start (const std::string &name, const std::vector< std::string > &args=std::vector< std::string >())
 Starts the given application. More...
 
bool Start (const std::string &name, std::streambuf *&buf, const std::vector< std::string > &args)
 This variant of start enables reading output of the application, buf is returned, ownership lies with the caller of the function. More...
 

Detailed Description

This namespace contains operating system related functionality.

All functions here behaves same way in all supported operating systems.

Function Documentation

◆ DisplayMessage()

void DisplayMessage ( const std::string &  message)

This function shows a OS message box to display errors, for other messages its better to use in-game dialogs.

◆ GetAppDataPath()

std::string GetAppDataPath ( )

Returns the directory where the system wide application data is stored.

Most probably it will be read only

◆ GetAppSettingPath()

std::string GetAppSettingPath ( )

Returns the directory where the system wide application settings is stored.

Most probably it will be read only

◆ GetEnvVar()

std::string GetEnvVar ( const std::string &  var)

Returns the value of an environment variable.

◆ GetInfo()

Info Gorgon::OS::GetInfo ( )

Returns information related with the operating system, including version, name, and architecture.

◆ GetName()

std::string GetName ( )

Returns the name of the current operating system in human readable form.

Might change from installation to installation.

References Gorgon::String::Extract(), and Gorgon::String::TrimStart().

◆ Initialize()

void Initialize ( )

Initializes operating system module.

Initializes the filesystem module.

Gorgon system requires every module to have initialization function even if they are not used. Currently used for following tasks:

  • Set startup directory

    There is a mechanism to ensure initialization is performed once.

◆ Open()

bool Open ( const std::string &  file)

Opens the given file with the related application.

This can also be a URI.

Returns
true if the given file is somehow opened. This includes open with dialog if it can be displayed

References GetEnvVar(), and Start().

◆ OpenTerminal()

void OpenTerminal ( )

Opens a terminal window to display output from the stdout.

This is not required for most operating systems and will not perform anything unless its necessary.

◆ processmessages()

void processmessages ( )

This method will notify the system should process any messages that coming from the operating system.

Internally used. Should only be used when necessary.

References Window::Windows.

◆ Start() [1/2]

bool Start ( const std::string &  name,
const std::vector< std::string > &  args = std::vector<std::string>() 
)

Starts the given application.

This application is searched from the installed applications unless it includes a path. You may use ./appname to start the appname from the current directory. The application is started in a separate process and the current process does not stop to wait its execution.

Warning
Depending on the operating system, executables in the current directory might take precedence even if no path is given.
Returns
true if the program is found and started. Does not check if the program continues working properly

References Gorgon::Filesystem::GetFilename().

◆ Start() [2/2]

bool Gorgon::OS::Start ( const std::string &  name,
std::streambuf *&  buf,
const std::vector< std::string > &  args 
)

This variant of start enables reading output of the application, buf is returned, ownership lies with the caller of the function.

References Gorgon::Filesystem::GetFilename().