![]() |
CARTA Backend
The backend component of CARTA
|
#include <string>
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. | |
#define VERSION_ID "5.0.0-dev" |
bool FindExecutablePath | ( | std::string & | path | ) |
Retrieves the absolute path of the currently running executable.
[out] | path | A reference to a string that will store the resolved executable path if successful. |
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
).
_NSGetExecutablePath
is used, and the buffer size is checked dynamically. /proc/self/exe
using readlink()
._NSGetExecutablePath
may fail, this implementation does not handle resizing the buffer. std::string GetReleaseInformation | ( | ) |
Retrieves the operating system release information.
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:
sw_vers
command and reads the output./etc/os-release
, which is available on most distributions using systemd.popen("sw_vers", "r")
is used to execute sw_vers
, which outputs OS version details./etc/os-release
file into a string.spdlog::warn
.std::string OutputOfCommand | ( | const char * | command | ) |
Executes a shell command and returns its output.
command | The shell command to execute. |
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
.
popen()
fails, an error message is printed, and an empty string is returned.popen()
fails.