diff options
-rw-r--r-- | backends/fs/ds/ds-fs.cpp | 4 | ||||
-rw-r--r-- | backends/fs/psp/psp-fs.cpp | 2 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/gbampsave.cpp | 2 | ||||
-rw-r--r-- | common/stream.cpp | 16 | ||||
-rw-r--r-- | common/stream.h | 6 |
5 files changed, 11 insertions, 19 deletions
diff --git a/backends/fs/ds/ds-fs.cpp b/backends/fs/ds/ds-fs.cpp index 0efee34369..272f34fd33 100644 --- a/backends/fs/ds/ds-fs.cpp +++ b/backends/fs/ds/ds-fs.cpp @@ -210,7 +210,7 @@ Common::SeekableReadStream *DSFileSystemNode::createReadStream() { Common::WriteStream *DSFileSystemNode::createWriteStream() { Common::WriteStream *stream = DSFileStream::makeFromPath(getPath(), true); - return Common::wrapBufferedWriteStream(stream, WRITE_BUFFER_SIZE, DisposeAfterUse::YES); + return Common::wrapBufferedWriteStream(stream, WRITE_BUFFER_SIZE); } ////////////////////////////////////////////////////////////////////////// @@ -392,7 +392,7 @@ Common::SeekableReadStream *GBAMPFileSystemNode::createReadStream() { Common::WriteStream *GBAMPFileSystemNode::createWriteStream() { Common::WriteStream *stream = DSFileStream::makeFromPath(getPath(), true); - return Common::wrapBufferedWriteStream(stream, WRITE_BUFFER_SIZE, DisposeAfterUse::YES); + return Common::wrapBufferedWriteStream(stream, WRITE_BUFFER_SIZE); } diff --git a/backends/fs/psp/psp-fs.cpp b/backends/fs/psp/psp-fs.cpp index b512f528c9..aecf96363c 100644 --- a/backends/fs/psp/psp-fs.cpp +++ b/backends/fs/psp/psp-fs.cpp @@ -259,7 +259,7 @@ Common::WriteStream *PSPFilesystemNode::createWriteStream() { Common::WriteStream *stream = PspIoStream::makeFromPath(getPath(), true); - return Common::wrapBufferedWriteStream(stream, WRITE_BUFFER_SIZE, DisposeAfterUse::YES); + return Common::wrapBufferedWriteStream(stream, WRITE_BUFFER_SIZE); } #endif //#ifdef __PSP__ diff --git a/backends/platform/ds/arm9/source/gbampsave.cpp b/backends/platform/ds/arm9/source/gbampsave.cpp index ea2e7e01de..ab7f3cff91 100644 --- a/backends/platform/ds/arm9/source/gbampsave.cpp +++ b/backends/platform/ds/arm9/source/gbampsave.cpp @@ -58,7 +58,7 @@ Common::OutSaveFile *GBAMPSaveFileManager::openForSaving(const Common::String &f Common::WriteStream *stream = DS::DSFileStream::makeFromPath(fileSpec, true); // Use a write buffer - stream = Common::wrapBufferedWriteStream(stream, SAVE_BUFFER_SIZE, DisposeAfterUse::YES); + stream = Common::wrapBufferedWriteStream(stream, SAVE_BUFFER_SIZE); return stream; } diff --git a/common/stream.cpp b/common/stream.cpp index b82a70409a..2abd6fc986 100644 --- a/common/stream.cpp +++ b/common/stream.cpp @@ -421,7 +421,6 @@ namespace { /** * Wrapper class which adds buffering to any WriteStream. */ -template <DisposeAfterUse::Flag _disposeParentStream> class BufferedWriteStream : public WriteStream { protected: WriteStream *_parentStream; @@ -462,8 +461,7 @@ public: const bool flushResult = flushBuffer(); assert(flushResult); - if (_disposeParentStream) - delete _parentStream; + delete _parentStream; delete[] _buf; } @@ -492,15 +490,9 @@ public: } // End of nameless namespace -WriteStream *wrapBufferedWriteStream(WriteStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream) { - if (parentStream) { - switch (disposeParentStream) { - case DisposeAfterUse::YES: - return new BufferedWriteStream<DisposeAfterUse::YES>(parentStream, bufSize); - case DisposeAfterUse::NO: - return new BufferedWriteStream<DisposeAfterUse::NO>(parentStream, bufSize); - } - } +WriteStream *wrapBufferedWriteStream(WriteStream *parentStream, uint32 bufSize) { + if (parentStream) + return new BufferedWriteStream(parentStream, bufSize); return 0; } diff --git a/common/stream.h b/common/stream.h index 14b1243ca0..9674375dd2 100644 --- a/common/stream.h +++ b/common/stream.h @@ -508,13 +508,13 @@ SeekableReadStream *wrapBufferedSeekableReadStream(SeekableReadStream *parentStr /** * Take an arbitrary WriteStream and wrap it in a custom stream which * transparently provides buffering. - * Users can specify how big the buffer should be, and whether the wrapped - * stream should be disposed when the wrapper is disposed. + * Users can specify how big the buffer should be. Currently, the + * parent stream is \em always disposed when the wrapper is disposed. * * It is safe to call this with a NULL parameter (in this case, NULL is * returned). */ -WriteStream *wrapBufferedWriteStream(WriteStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream); +WriteStream *wrapBufferedWriteStream(WriteStream *parentStream, uint32 bufSize); /** * Simple memory based 'stream', which implements the ReadStream interface for |