Writes a file to the file system.
More...
#include <FileWriter.hpp>
|
| 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 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.).
◆ FileWriter()
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.
- Parameters
-
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. |
◆ write() [1/3]
bool switchboard::FileWriter::write |
( |
const int8 * |
buffer, |
|
|
const uint64 |
size |
|
) |
| |
|
noexcept |
Writes content of buffer in the destination file.
- Parameters
-
buffer | Raw data buffer. |
size | Size of the raw data buffer. |
- Returns
- True if write is successful, false otherwise.
◆ write() [2/3]
const bool switchboard::FileWriter::write |
( |
const std::string |
filePath, |
|
|
const int8 * |
buffer, |
|
|
const uint64 |
size |
|
) |
| |
|
static |
Writes contents of input buffer to a file at filePath.
- Parameters
-
filePath | Path of the file to write to. |
buffer | Buffer with the input data. |
size | Size of the input buffer in bytes. |
- Returns
- True if the data was written successfully, false otherwise.
◆ write() [3/3]
bool switchboard::FileWriter::write |
( |
const std::vector< int8 > & |
buffer | ) |
|
|
noexcept |
Writes content of buffer in the destination file.
- Parameters
-
- Returns
- True if write is successful, false otherwise.
The documentation for this class was generated from the following files:
- /Users/jenkins/.jenkins/workspace/Switchboard Developer Site - Production/SwitchboardSDK/src/all/File/FileWriter.hpp
- /Users/jenkins/.jenkins/workspace/Switchboard Developer Site - Production/SwitchboardSDK/src/all/File/FileWriter.cpp