CARTA Backend
The backend component of CARTA
Loading...
Searching...
No Matches
App.h File Reference
#include <string>
Include dependency graph for App.h:
This graph shows which files directly or indirectly include this file:

Macros

#define VERSION_ID   "5.0.0-dev"
 

Functions

bool FindExecutablePath (std::string &path)
 Retrieves the absolute path of the currently running executable.
 
std::string GetReleaseInformation ()
 Retrieves the operating system release information.
 
std::string OutputOfCommand (const char *command)
 Executes a shell command and returns its output.
 

Macro Definition Documentation

◆ VERSION_ID

#define VERSION_ID   "5.0.0-dev"

Function Documentation

◆ FindExecutablePath()

bool FindExecutablePath ( std::string &  path)

Retrieves the absolute path of the currently running executable.

Parameters
[out]pathA reference to a string that will store the resolved executable path if successful.
Returns
true if the executable path was successfully retrieved, false otherwise.

This function determines the full path of the running executable and stores it in the path parameter. It supports both macOS (_NSGetExecutablePath) and Linux (/proc/self/exe).

Note
On macOS, _NSGetExecutablePath is used, and the buffer size is checked dynamically.
On Linux, the function reads from /proc/self/exe using readlink().
Warning
On macOS, if the buffer is too small, _NSGetExecutablePath may fail, this implementation does not handle resizing the buffer.
Here is the caller graph for this function:

◆ GetReleaseInformation()

std::string GetReleaseInformation ( )

Retrieves the operating system release information.

Returns
A std::string containing the OS release information. If the information is unavailable or an error occurs, the function returns "Platform information not available".

This function fetches OS release details using platform-specific methods:

  • On macOS, it runs the sw_vers command and reads the output.
  • On Linux/Unix, it attempts to read /etc/os-release, which is available on most distributions using systemd.
Note
  • On macOS, popen("sw_vers", "r") is used to execute sw_vers, which outputs OS version details.
  • On Linux, the function reads the /etc/os-release file into a string.
  • If an error occurs while reading the file, a warning is logged via spdlog::warn.
Warning
  • The function does not support Windows.
  • On macOS, buffer overflow protection is in place, but the buffer size is fixed.
Here is the caller graph for this function:

◆ OutputOfCommand()

std::string OutputOfCommand ( const char *  command)

Executes a shell command and returns its output.

Parameters
commandThe shell command to execute.
Returns
A std::string containing the command's output. If execution fails, an empty string is returned.

This function opens a pipe using popen() to execute the given command, reads its output, and returns it as a std::string.

Note
  • The function trims trailing newline characters from the output.
  • The caller must ensure the command is safe to execute (avoid shell injection).
  • Works only on Unix-like systems.
Warning
  • If popen() fails, an error message is printed, and an empty string is returned.
  • The function does not handle command execution failures beyond detecting if popen() fails.
Here is the caller graph for this function: