| Revision 2728,
1.1 KB
checked in by chris, 21 months ago
(diff) |
|
Implement write buffering on directories.
|
-
Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 | // -------------------------------------------------------------------------- |
|---|
| 2 | // |
|---|
| 3 | // File |
|---|
| 4 | // Name: BufferedWriteStream.h |
|---|
| 5 | // Purpose: Buffering write-only wrapper around IOStreams |
|---|
| 6 | // Created: 2010/09/13 |
|---|
| 7 | // |
|---|
| 8 | // -------------------------------------------------------------------------- |
|---|
| 9 | |
|---|
| 10 | #ifndef BUFFEREDWRITESTREAM__H |
|---|
| 11 | #define BUFFEREDWRITESTREAM__H |
|---|
| 12 | |
|---|
| 13 | #include "IOStream.h" |
|---|
| 14 | |
|---|
| 15 | class BufferedWriteStream : public IOStream |
|---|
| 16 | { |
|---|
| 17 | private: |
|---|
| 18 | IOStream& mrSink; |
|---|
| 19 | char mBuffer[4096]; |
|---|
| 20 | int mBufferPosition; |
|---|
| 21 | |
|---|
| 22 | public: |
|---|
| 23 | BufferedWriteStream(IOStream& rSource); |
|---|
| 24 | virtual ~BufferedWriteStream() { Close(); } |
|---|
| 25 | |
|---|
| 26 | virtual int Read(void *pBuffer, int NBytes, int Timeout = IOStream::TimeOutInfinite); |
|---|
| 27 | virtual pos_type BytesLeftToRead(); |
|---|
| 28 | virtual void Write(const void *pBuffer, int NBytes); |
|---|
| 29 | virtual pos_type GetPosition() const; |
|---|
| 30 | virtual void Seek(IOStream::pos_type Offset, int SeekType); |
|---|
| 31 | virtual void Flush(int Timeout = IOStream::TimeOutInfinite); |
|---|
| 32 | virtual void Close(); |
|---|
| 33 | |
|---|
| 34 | virtual bool StreamDataLeft(); |
|---|
| 35 | virtual bool StreamClosed(); |
|---|
| 36 | |
|---|
| 37 | private: |
|---|
| 38 | BufferedWriteStream(const BufferedWriteStream &rToCopy) |
|---|
| 39 | : mrSink(rToCopy.mrSink) { /* do not call */ } |
|---|
| 40 | }; |
|---|
| 41 | |
|---|
| 42 | #endif // BUFFEREDWRITESTREAM__H |
|---|
| 43 | |
|---|
| 44 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.