StormByte C++ Library 1.2.0
StormByte is a comprehensive, cross-platform C++ library aimed at easing system programming, configuration management, logging, and database handling tasks. This library provides a unified API that abstracts away the complexities and inconsistencies of different platforms (Windows, Linux).
Loading...
Searching...
No Matches
Functions
StormByte::System Namespace Reference

Path and timing helpers that hide OS differences. More...

Functions

std::filesystem::path TempFileName (const std::string &prefix="TMP")
 Creates a unique temporary file and returns its path.
 
std::filesystem::path CurrentPath ()
 Current working directory.
 
std::filesystem::path ExecutablePath ()
 Directory that contains the running executable.
 
template<typename Rep , typename Period >
void Sleep (const std::chrono::duration< Rep, Period > &duration)
 Suspends the calling thread.
 

Detailed Description

Path and timing helpers that hide OS differences.

Function Documentation

◆ CurrentPath()

std::filesystem::path StormByte::System::CurrentPath ( )

Current working directory.

Returns
Absolute path of the process cwd.
Exceptions
StormByte::SystemErrorIf the cwd cannot be obtained.

◆ ExecutablePath()

std::filesystem::path StormByte::System::ExecutablePath ( )

Directory that contains the running executable.

Returns
That directory.
Exceptions
StormByte::SystemErrorIf the executable path cannot be resolved.

◆ Sleep()

template<typename Rep , typename Period >
void StormByte::System::Sleep ( const std::chrono::duration< Rep, Period > &  duration)

Suspends the calling thread.

Template Parameters
RepDuration representation.
PeriodDuration period.
Parameters
durationSleep interval.

◆ TempFileName()

std::filesystem::path StormByte::System::TempFileName ( const std::string &  prefix = "TMP")

Creates a unique temporary file and returns its path.

Parameters
prefixFile-name prefix. Default "TMP". On Windows, GetTempFileNameW only uses the first three characters.
Returns
Absolute path of the created empty file.
Exceptions
StormByte::SystemErrorIf the path cannot be obtained or the file cannot be created.

The file is created (POSIX: mkstemp, Windows: GetTempFileNameW) and left on disk. The caller owns the unlink.