Plasma Engine  2.0
Loading...
Searching...
No Matches
DeferredFileWriter.h
1#pragma once
2
3#include <Foundation/IO/FileSystem/FileWriter.h>
4#include <Foundation/IO/MemoryStream.h>
5
8class PL_FOUNDATION_DLL plDeferredFileWriter : public plStreamWriter
9{
10 PL_DISALLOW_COPY_AND_ASSIGN(plDeferredFileWriter);
11
12public:
14
16 ~plDeferredFileWriter() { Close().IgnoreResult(); }
17
19 void SetOutput(plStringView sFileToWriteTo, bool bOnlyWriteIfDifferent = false); // [tested]
20
21 virtual plResult WriteBytes(const void* pWriteBuffer, plUInt64 uiBytesToWrite) override; // [tested]
22
25 plResult Close(bool* out_pWasWrittenTo = nullptr); // [tested]
26
29 void Discard(); // [tested]
30
31private:
32 bool m_bOnlyWriteIfDifferent = false;
33 bool m_bAlreadyClosed = false;
34 plString m_sOutputFile;
36 plMemoryStreamWriter m_Writer;
37};
The default implementation for memory stream storage.
Definition MemoryStream.h:161
A file writer that caches all written data and only opens and writes to the output file when everythi...
Definition DeferredFileWriter.h:9
~plDeferredFileWriter()
Upon destruction the file is closed and thus written, unless Discard was called before.
Definition DeferredFileWriter.h:16
A writer which can access a memory stream.
Definition MemoryStream.h:313
Interface for binary out (write) streams.
Definition Stream.h:107
virtual plResult WriteBytes(const void *pWriteBuffer, plUInt64 uiBytesToWrite)=0
Writes a raw number of bytes from the buffer, this is the only method which has to be implemented to ...
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54