Giri's C++ Support Library
C++ library providing everything you need to quickly create awesome applications.
giri::FileSystem Namespace Reference

Namespace containing FileSystem I/O commands. More...

Classes

class  FileSystemException
 Exception to be thrown on FileSystem errors. More...
 

Functions

std::vector< char > LoadFile (const std::filesystem::path &file)
 
bool WriteFile (const std::filesystem::path &file, const std::vector< char > &data)
 
std::filesystem::path FindExecutableInPath (const std::string &executable)
 
std::string ExecuteSync (const std::string &cmd)
 
std::future< void > ExecuteAsync (const std::string &cmd, std::ostream &ostr=std::cout)
 

Detailed Description

Namespace containing FileSystem I/O commands.

Function Documentation

◆ ExecuteAsync()

std::future<void> giri::FileSystem::ExecuteAsync ( const std::string &  cmd,
std::ostream &  ostr = std::cout 
)
inline

Executes a command asynchronously.

Parameters
cmdCommand to execute.
ostrStream to write command output to. (defaults to std::cout)
Returns
Future object which can be used for synchronization.

◆ ExecuteSync()

std::string giri::FileSystem::ExecuteSync ( const std::string &  cmd)
inline

Executes a command synchronously.

Parameters
cmdCommand to execute.
Returns
The output of the command after finishing execution.

◆ FindExecutableInPath()

std::filesystem::path giri::FileSystem::FindExecutableInPath ( const std::string &  executable)
inline

Searches for an executable within PATH.

Parameters
executableName of executable to search for.
Returns
Path to executable if existent, emtpty string if not existent.

◆ LoadFile()

std::vector<char> giri::FileSystem::LoadFile ( const std::filesystem::path &  file)
inline

Loads blob data from the harddisk. Throws FileSystemException on error.

Parameters
fileFilepath to load data from.

◆ WriteFile()

bool giri::FileSystem::WriteFile ( const std::filesystem::path &  file,
const std::vector< char > &  data 
)
inline

Writes data to the harddisk. If given file does not exist it will be created. If file does already exist it will be overridden.

Parameters
fileFilepath to write data to.
dataData to write.
Returns
true on success, false on failure.