SPH
Classes | Functions
Platform.cpp File Reference
#include "system/Platform.h"
#include "io/FileSystem.h"
#include "objects/containers/StaticArray.h"
#include "objects/wrappers/Finally.h"
#include <fcntl.h>
#include <libgen.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/times.h>
#include <unistd.h>

Go to the source code of this file.

Classes

class  CpuUsage
 

Functions

NAMESPACE_SPH_BEGIN Expected< PathgetExecutablePath ()
 Returns the absolute path to the currently running executable. More...
 
Outcome sendMail (const std::string &to, const std::string &from, const std::string &subject, const std::string &message)
 Sends a mail with given message. More...
 
Outcome showNotification (const std::string &title, const std::string &message)
 Shows a notification using 'notify-send' command. More...
 
Outcome sendPushNotification (const std::string &key, const std::string &title, const std::string &message)
 Sends a push notification to an Android device, using SimplePush API. More...
 
Expected< std::string > getGitCommit (const Path &pathToGitRoot, const Size prev)
 Returns git commit hash of the current or older commit as string. More...
 
Optional< FloatgetCpuUsage ()
 
bool isDebuggerPresent ()
 Returns true if the program is running with attached debugger. More...
 

Function Documentation

◆ getCpuUsage()

Optional<Float> getCpuUsage ( )

Definition at line 144 of file Platform.cpp.

◆ getExecutablePath()

NAMESPACE_SPH_BEGIN Expected<Path> getExecutablePath ( )

Returns the absolute path to the currently running executable.

Definition at line 15 of file Platform.cpp.

◆ getGitCommit()

Expected<std::string> getGitCommit ( const Path pathToGitRoot,
const Size  prev = 0 
)

Returns git commit hash of the current or older commit as string.

If the git repository is not found or command fails, returns error message

Parameters
pathToGitRootPath to where the source code is located
prevNumber of commits into the history. For 0, the current commit is returned.

Definition at line 63 of file Platform.cpp.

◆ isDebuggerPresent()

bool isDebuggerPresent ( )

Returns true if the program is running with attached debugger.

Definition at line 149 of file Platform.cpp.

◆ sendMail()

Outcome sendMail ( const std::string &  to,
const std::string &  from,
const std::string &  subject,
const std::string &  message 
)

Sends a mail with given message.

Definition at line 26 of file Platform.cpp.

◆ sendPushNotification()

Outcome sendPushNotification ( const std::string &  key,
const std::string &  title,
const std::string &  message 
)

Sends a push notification to an Android device, using SimplePush API.

Requires installed curl on the system.

Parameters
keySimplePush key of the Android device.
titleTitle of the notification.
messageNotification message.

Definition at line 53 of file Platform.cpp.

◆ showNotification()

Outcome showNotification ( const std::string &  title,
const std::string &  message 
)

Shows a notification using 'notify-send' command.

The function is non-blocking, the notification disappears on timeout or when user hides it.

Definition at line 44 of file Platform.cpp.