StormByte-System 2.0.0
C++26 process and environment module of the StormByte suite
 
Loading...
Searching...
No Matches
StormByte::System::File Namespace Reference

File locations of this process. More...

Enumerations

enum class  Error { Success = 0 , Permission , NotFound , Failed }
 File enumerators. More...
 

Functions

StormByte::Error::Fault LastError () noexcept
 Last File error on this thread.
 
bool Temporary (StormByte::String::String &path, std::string_view prefix="TMP", std::string_view suffix={})
 Create a unique empty temporary file.
 
bool CurrentExecutable (StormByte::String::String &path)
 Full path of the running executable.
 

Detailed Description

File locations of this process.

Each call returns true on success and updates LastError for this thread. An output String is valid only when the call returned true. The caller unlinks a file created by Temporary.

Enumeration Type Documentation

◆ Error

enum class StormByte::System::File::Error
strong

File enumerators.

Domain tag StormByte.System.File. Zero is success.

Enumerator
Success 

No error.

Permission 

The process may not create or read this file.

NotFound 

The file could not be resolved.

Failed 

The platform call failed.

Function Documentation

◆ CurrentExecutable()

bool StormByte::System::File::CurrentExecutable ( StormByte::String::String &  path)

Full path of the running executable.

Parameters
[out]pathAbsolute file path. Written only on success.
Returns
true if the path was resolved.

◆ LastError()

StormByte::Error::Fault StormByte::System::File::LastError ( )
noexcept

Last File error on this thread.

Returns
Success or an Error code. Stored in the System module TLS.

◆ Temporary()

bool StormByte::System::File::Temporary ( StormByte::String::String &  path,
std::string_view  prefix = "TMP",
std::string_view  suffix = {} 
)

Create a unique empty temporary file.

Parameters
[out]pathAbsolute path of the created file. Written only on success.
prefixFile-name prefix. Default "TMP".
suffixFile-name suffix (including a leading dot if wanted). Default empty.
Returns
true if the file was created.

POSIX uses mkstemp / mkstemps. Windows uses GetTempFileNameW and only the first three prefix characters; the suffix is appended after the generated name when it is not empty.