class EE::System::Sys¶
Overview¶
#include <sys.hpp> class Sys { public: // enums enum PlatformType; // methods static Uint64 getProcessID(); static std::string getDateTimeStr(); static std::string epochToString(const Uint64& epochTimestamp, const std::string& format = "%Y-%m-%d %H:%M"); static std::string getConfigPath(const std::string& appname); static std::string getTempPath(); static Uint64 getTicks(); static void sleep(const Time& time); static std::string getProcessPath(); static std::string getProcessFilePath(); static double getSystemTime(); static std::string getOSName(bool showReleaseName = false); static std::string getOSArchitecture(); static std::string getPlatform(); static Sys::PlatformType getPlatformType(); static int getCPUCount(); static void* loadObject(const std::string& sofile); static void unloadObject(void* handle); static void* loadFunction(void* handle, const std::string& name); static std::vector<std::string> parseArguments(int argc, char* argv[]); static std::vector<std::string> getLogicalDrives(); static std::string which(const std::string& exeName, const std::vector<std::string>& customSearchPaths = {}); static std::string getEnv(const std::string& name); static std::vector<std::string> getEnvSplitted(const std::string& name); static bool windowAttachConsole(); static void execute(const std::string& cmd, const std::string& workingDir = ""); static bool isMobile(); static std::unordered_map<std::string, std::string> getEnvironmentVariables(); static std::vector<Uint64> pidof(const std::string& processName); static Int64 getProcessCreationTime(Uint64 pid); static std::string getShortcutTarget(const std::string& lnkFilePath); static std::string getUserDirectory(); };
Detailed Documentation¶
Methods¶
static Uint64 getProcessID()
Returns:
The current process id
static std::string getDateTimeStr()
Returns:
the current date time
static std::string epochToString(const Uint64& epochTimestamp, const std::string& format = "%Y-%m-%d %H:%M")
Converts any epoch timestmap to a formatted string.
static std::string getConfigPath(const std::string& appname)
Returns:
A storage path for config files for every platform
static std::string getTempPath()
Returns:
The path of the directory designated for temporary files.
static Uint64 getTicks()
Returns:
The number of milliseconds since the first call. Note that this value wraps if the program runs for more than ~49 days.
static void sleep(const Time& time)
Wait the time defined before returning.
static std::string getProcessPath()
Returns:
The application path ( the executable path without the executable )
static std::string getProcessFilePath()
Returns:
The process path ( the executable file path )
static double getSystemTime()
Returns:
static std::string getOSName(bool showReleaseName = false)
Parameters:
showReleaseName |
Instead of returning only the OS Name, it will append the release name or number. For Windows instead of “Windows” it will be “Windows 7”, for “Linux” it will be “Linux 3.15” and so on. |
Returns:
The OS Name
static std::string getOSArchitecture()
Returns:
The OS Architecture
static std::string getPlatform()
Returns:
The platform name.
static Sys::PlatformType getPlatformType()
Returns:
The platform type.
static int getCPUCount()
Returns:
The Number of CPUs of the system.
static void* loadObject(const std::string& sofile)
Dynamically load a shared object and return a pointer to the object handle.
Parameters:
sofile |
a system dependent name of the object file |
Returns:
The pointer to the object handle or NULL if there was an error
static void unloadObject(void* handle)
Unloads a shared object from memory.
Parameters:
handle |
The object handle of the shared object to unload |
static void* loadFunction(void* handle, const std::string& name)
Looks up the address of the named function in the shared object and return it.
Parameters:
handle |
A valid shared object handle returned by Sys::LoadObject() |
name |
The name of the function to look up |
Returns:
The pointer to the function or NULL if there was an error
static std::vector<std::string> parseArguments(int argc, char* argv[])
Returns:
the argument list in a vector of std::strings in UTF-8, ignoring the first argument (the binary name)
static std::vector<std::string> getLogicalDrives()
Returns:
The OS logical drives
static std::string which(const std::string& exeName, const std::vector<std::string>& customSearchPaths = {})
Finds the location of a binary / executable file.
Returns:
The executable file path, or an empty string if not found.
static std::string getEnv(const std::string& name)
Returns:
An environment variable
static std::vector<std::string> getEnvSplitted(const std::string& name)
Returns:
A splitted environment variable
static bool windowAttachConsole()
It will attach the console to the parent process console if any. Windows only function. Other platforms will do nothing.
static void execute(const std::string& cmd, const std::string& workingDir = "")
Executes a command
static bool isMobile()
Returns:
True if current running platform / os is a mobile one
static std::unordered_map<std::string, std::string> getEnvironmentVariables()
Returns:
The process environment variables
static std::vector<Uint64> pidof(const std::string& processName)
Returns:
The process ids found with the correspoding process / binary / executable name
static Int64 getProcessCreationTime(Uint64 pid)
Returns:
The unix timestamp of the process creation time
static std::string getShortcutTarget(const std::string& lnkFilePath)
Returns:
The target destination of a windows shortcut path (.lnk files)
static std::string getUserDirectory()
Returns:
The user home directory