libnick 2024.12.0
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
Nickvision::Helpers::CodeHelpers Namespace Reference

Functions

std::string getLastSystemError ()
 Get the last system api call error message.
 
std::vector< std::byte > readFileBytes (const std::filesystem::path &path)
 Reads a file as a vector of bytes.
 
template<typename T >
const T & unmove (T &&t)
 Unmoves a value.
 
bool writeFileBytes (const std::filesystem::path &path, const std::vector< std::byte > &bytes, bool overwrite=true)
 Writes a vector of bytes to a file.
 

Function Documentation

◆ getLastSystemError()

std::string Nickvision::Helpers::CodeHelpers::getLastSystemError ( )

Get the last system api call error message.

Returns
The last system error message

◆ readFileBytes()

std::vector< std::byte > Nickvision::Helpers::CodeHelpers::readFileBytes ( const std::filesystem::path & path)

Reads a file as a vector of bytes.

Parameters
pathThe path to the file
Returns
The bytes from the file

◆ unmove()

template<typename T >
const T & Nickvision::Helpers::CodeHelpers::unmove ( T && t)

Unmoves a value.

Parameters
tAn rvalue of T
Returns
The lvalue of t

◆ writeFileBytes()

bool Nickvision::Helpers::CodeHelpers::writeFileBytes ( const std::filesystem::path & path,
const std::vector< std::byte > & bytes,
bool overwrite = true )

Writes a vector of bytes to a file.

Parameters
pathThe path to the file
bytesThe bytes to write
overwriteWhether or not to overwrite the file if it already exists
Returns
True if successful, false otherwise. False is returned if overwrite is false and the file exists.