From 169edfccf30e9355e7d77d8b48615b0bda7b52bd Mon Sep 17 00:00:00 2001 From: Lars Persson Date: Thu, 11 Sep 2008 21:32:40 +0000 Subject: Added SymbianStream.h for SymbianStdioStream definition Renamed Symbian stream implementation to SymbianStdioStream instead of StdioStream. svn-id: r34498 --- backends/fs/symbian/symbian-fs.cpp | 11 ++++--- backends/fs/symbian/symbianstream.cpp | 30 ++++++++--------- backends/fs/symbian/symbianstream.h | 62 +++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 20 deletions(-) create mode 100644 backends/fs/symbian/symbianstream.h (limited to 'backends/fs') diff --git a/backends/fs/symbian/symbian-fs.cpp b/backends/fs/symbian/symbian-fs.cpp index ddbbe7071d..1c6d8435a9 100644 --- a/backends/fs/symbian/symbian-fs.cpp +++ b/backends/fs/symbian/symbian-fs.cpp @@ -24,8 +24,8 @@ #if defined (__SYMBIAN32__) #include "backends/fs/abstract-fs.h" -#include "backends/fs/stdiostream.h" -#include "backends/platform/symbian/src/SymbianOS.h" +#include "backends/fs/symbian/symbianstream.h" +#include "backends/platform/symbian/src/symbianos.h" #include #include @@ -253,11 +253,12 @@ AbstractFilesystemNode *SymbianFilesystemNode::getParent() const { } Common::SeekableReadStream *SymbianFilesystemNode::openForReading() { - return StdioStream::makeFromPath(getPath().c_str(), false); + return SymbianStdioStream::makeFromPath(getPath().c_str(), false); } Common::WriteStream *SymbianFilesystemNode::openForWriting() { - return StdioStream::makeFromPath(getPath().c_str(), true); + return SymbianStdioStream::makeFromPath(getPath().c_str(), true); } - #endif //#if defined (__SYMBIAN32__) + + diff --git a/backends/fs/symbian/symbianstream.cpp b/backends/fs/symbian/symbianstream.cpp index 3ac133c95f..61fc5a04fb 100644 --- a/backends/fs/symbian/symbianstream.cpp +++ b/backends/fs/symbian/symbianstream.cpp @@ -24,9 +24,9 @@ */ #include "common/scummsys.h" -#include "backends/fs/StdioStream.h" +#include "backends/fs/symbian/symbianstream.h" #include "common/system.h" -#include "backends/platform/symbian/src/SymbianOS.h" +#include "backends/platform/symbian/src/symbianos.h" #include @@ -173,31 +173,31 @@ size_t ReadData(const void* ptr, size_t size, size_t numItems, TSymbianFileEntry return pointer.Length() / size; } -StdioStream::StdioStream(void *handle) : _handle(handle) { +SymbianStdioStream::SymbianStdioStream(void *handle) : _handle(handle) { assert(handle); } -StdioStream::~StdioStream() { +SymbianStdioStream::~SymbianStdioStream() { ((TSymbianFileEntry*)(_handle))->_fileHandle.Close(); delete (TSymbianFileEntry*)(_handle); } -bool StdioStream::ioFailed() const { +bool SymbianStdioStream::ioFailed() const { return eos() || ((TSymbianFileEntry*)(_handle))->_lastError != 0; } -void StdioStream::clearIOFailed() { +void SymbianStdioStream::clearIOFailed() { ((TSymbianFileEntry*)(_handle))->_lastError = 0; } -bool StdioStream::eos() const { +bool SymbianStdioStream::eos() const { TSymbianFileEntry* entry = ((TSymbianFileEntry*)(_handle)); return entry->_eofReached != 0; } -uint32 StdioStream::pos() const { +uint32 SymbianStdioStream::pos() const { TInt pos = 0; TSymbianFileEntry* entry = ((TSymbianFileEntry*)(_handle)); @@ -210,7 +210,7 @@ uint32 StdioStream::pos() const { return pos; } -uint32 StdioStream::size() const { +uint32 SymbianStdioStream::size() const { TInt length = 0; ((TSymbianFileEntry*)(_handle))->_fileHandle.Size(length); @@ -218,7 +218,7 @@ uint32 StdioStream::size() const { return length; } -void StdioStream::seek(int32 offs, int whence) { +void SymbianStdioStream::seek(int32 offs, int whence) { assert(_handle); TSeek seekMode = ESeekStart; @@ -249,11 +249,11 @@ void StdioStream::seek(int32 offs, int whence) { } } -uint32 StdioStream::read(void *ptr, uint32 len) { +uint32 SymbianStdioStream::read(void *ptr, uint32 len) { return (uint32)ReadData((byte *)ptr, 1, len, (TSymbianFileEntry *)_handle); } -uint32 StdioStream::write(const void *ptr, uint32 len) { +uint32 SymbianStdioStream::write(const void *ptr, uint32 len) { TPtrC8 pointer( (unsigned char*) ptr, len); ((TSymbianFileEntry*)(_handle))->_inputPos = KErrNotFound; @@ -267,14 +267,14 @@ uint32 StdioStream::write(const void *ptr, uint32 len) { return 0; } -void StdioStream::flush() { +void SymbianStdioStream::flush() { ((TSymbianFileEntry*)(_handle))->_fileHandle.Flush(); } -StdioStream *StdioStream::makeFromPath(const Common::String &path, bool writeMode) { +SymbianStdioStream *SymbianStdioStream::makeFromPath(const Common::String &path, bool writeMode) { void *handle = CreateSymbianFileEntry(path.c_str(), writeMode ? "wb" : "rb"); if (handle) - return new StdioStream(handle); + return new SymbianStdioStream(handle); return 0; } diff --git a/backends/fs/symbian/symbianstream.h b/backends/fs/symbian/symbianstream.h new file mode 100644 index 0000000000..776446c5f5 --- /dev/null +++ b/backends/fs/symbian/symbianstream.h @@ -0,0 +1,62 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL: $ + * $Id: $ + * + */ + +#ifndef BACKENDS_FS_SYMBIANSTDIOSTREAM_H +#define BACKENDS_FS_SYMBIANSTDIOSTREAM_H + +#include "common/scummsys.h" +#include "common/noncopyable.h" +#include "common/stream.h" +#include "common/str.h" + +class SymbianStdioStream : public Common::SeekableReadStream, public Common::WriteStream, public Common::NonCopyable { +protected: + /** File handle to the actual file. */ + void *_handle; + +public: + /** + * Given a path, invokes fopen on that path and wrap the result in a + * StdioStream instance. + */ + static SymbianStdioStream *makeFromPath(const Common::String &path, bool writeMode); + + SymbianStdioStream(void *handle); + virtual ~SymbianStdioStream(); + + bool ioFailed() const; + void clearIOFailed(); + bool eos() const; + + virtual uint32 write(const void *dataPtr, uint32 dataSize); + virtual void flush(); + + virtual uint32 pos() const; + virtual uint32 size() const; + void seek(int32 offs, int whence = SEEK_SET); + uint32 read(void *dataPtr, uint32 dataSize); +}; + +#endif -- cgit v1.2.3