|
OpenEnroth d1a3925
|
#include <FileOutputStream.h>
Public Member Functions | |
| FileOutputStream ()=default | |
| FileOutputStream (std::string_view path, size_t bufferSize=DEFAULT_BUFFER_SIZE) | |
| virtual | ~FileOutputStream () |
| void | open (std::string_view path, size_t bufferSize=DEFAULT_BUFFER_SIZE) |
Public Member Functions inherited from OutputStream | |
| virtual | ~OutputStream () |
| void | write (const void *data, size_t size) |
| void | write (std::string_view s) |
| void | write (const Blob &blob) |
| void | flush () |
| void | close () |
| bool | isOpen () const |
| size_t | position () const |
| size_t | size () const |
| const std::string & | displayPath () const |
Static Public Attributes | |
| static constexpr size_t | DEFAULT_BUFFER_SIZE = 1024 * 1024 |
Private Types | |
| using | base_type = OutputStream |
Private Member Functions | |
| virtual void | _overflow (Buffer *buffer, const void *data, size_t size) override |
| virtual void | _flush (Buffer *buffer) override |
| virtual void | _close (Buffer *buffer, bool canThrow) override |
| void | writeBuffer (const Buffer &buffer, bool canThrow) |
Private Attributes | |
| FILE * | _file = nullptr |
| std::unique_ptr< char[]> | _buf |
| size_t | _bufSize = 0 |
Additional Inherited Members | |
Public Types inherited from OutputStream | |
| using | Buffer = StreamBuffer< char > |
Protected Member Functions inherited from OutputStream | |
| OutputStream ()=default | |
| void | open (Buffer buffer, std::string_view displayPath) |
| virtual void | _overflow (Buffer *buffer, const void *data, size_t size)=0 |
| virtual void | _flush (Buffer *buffer)=0 |
| virtual void | _close (Buffer *buffer, bool canThrow)=0 |
| void | destroy () noexcept |
Output stream that writes to a file.
|
private |
|
default |
|
explicit |
|
virtual |
|
overrideprivatevirtual |
Flushes any remaining buffered data and releases held resources.
Derived implementations should call OutputStream::_close() at the end.
| [in,out] | buffer | Current buffer state. |
| canThrow | Whether the implementation is allowed to throw. When called from a destructor via destroy(), this is false and the implementation should do best-effort cleanup without throwing. |
| Exception | On error, only if canThrow is true. |
Implements OutputStream.
|
overrideprivatevirtual |
Flushes buffered data to the underlying target.
| [in,out] | buffer | Current buffer state. |
| Exception | On error. |
Implements OutputStream.
|
overrideprivatevirtual |
Called when a write doesn't fit in the current buffer. Implementations should handle the overflow data (write it out or store it), and provide a new writable buffer via the out parameter.
| [in,out] | buffer | Current buffer state on input. Set to the new buffer state on output. Data in [buffer->start, buffer->pos) is treated as dirty (not yet flushed). |
| data | Pointer to the overflow data to write. | |
| size | Size of the overflow data, always greater than buffer->remaining(). |
| Exception | On error. |
Implements OutputStream.
| void FileOutputStream::open | ( | std::string_view | path, |
| size_t | bufferSize = DEFAULT_BUFFER_SIZE |
||
| ) |
|
private |
|
private |
|
private |
|
private |
|
staticconstexpr |