Switchboard SDK
|
Writes a file to the file system. More...
#include <FileWriter.hpp>
Public Member Functions | |
FileWriter (const std::string &filePath, bool allowOverwrite=true) | |
Tries to create FileWriter by opening an output stream. Throws std::runtime_error if could not open file. | |
~FileWriter () | |
FileWriter destructor. | |
FileWriter (const FileWriter &)=delete | |
bool | write (const int8 *buffer, const uint64 size) noexcept |
Writes content of buffer in the destination file. | |
bool | write (const std::vector< int8 > &buffer) noexcept |
Writes content of buffer in the destination file. | |
Static Public Member Functions | |
static const bool | write (const std::string filePath, const int8 *buffer, const uint64 size) |
Writes contents of input buffer to a file at filePath. | |
Writes a file to the file system.
FileWriter class for writing raw data to a file.
Resource acquisition happens when constructing FileWriter. Destruction ensures that the file is closed.
Reading from the file can happen after closing it (destructing FileWriter, by scoping it, calling reset on a unique_ptr, etc.).
switchboard::FileWriter::FileWriter | ( | const std::string & | filePath, |
bool | allowOverwrite = true ) |
Tries to create FileWriter by opening an output stream. Throws std::runtime_error if could not open file.
filePath | Destination file path. |
allowOverwrite | Indicates if only non-existent file should be opened. If this is false and there is already a file at filePath, throw std::runtime_error. |
|
noexcept |
Writes content of buffer in the destination file.
buffer | Raw data buffer. |
size | Size of the raw data buffer. |
|
static |
Writes contents of input buffer to a file at filePath.
filePath | Path of the file to write to. |
buffer | Buffer with the input data. |
size | Size of the input buffer in bytes. |
|
noexcept |
Writes content of buffer in the destination file.
buffer | Raw data vector. |