aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMax Horn2008-09-03 11:49:02 +0000
committerMax Horn2008-09-03 11:49:02 +0000
commit320a5dc99fa416d63a5fb8ec63c07463c80dc633 (patch)
tree8ed0d2586f70fc9ab24857395b17758cb47e14ec /common
parent531bcf847ceef2b9eca82e0b3ef8473612889632 (diff)
downloadscummvm-rg350-320a5dc99fa416d63a5fb8ec63c07463c80dc633.tar.gz
scummvm-rg350-320a5dc99fa416d63a5fb8ec63c07463c80dc633.tar.bz2
scummvm-rg350-320a5dc99fa416d63a5fb8ec63c07463c80dc633.zip
Moved StdioStream to its own files inside backends
svn-id: r34303
Diffstat (limited to 'common')
-rw-r--r--common/file.cpp63
-rw-r--r--common/file.h23
2 files changed, 0 insertions, 86 deletions
diff --git a/common/file.cpp b/common/file.cpp
index 6083e5547d..cc9ae01baf 100644
--- a/common/file.cpp
+++ b/common/file.cpp
@@ -557,67 +557,4 @@ void DumpFile::flush() {
fflush((FILE *)_handle);
}
-
-StdioStream::StdioStream(void *handle) : _handle(handle) {
- assert(handle);
-}
-
-StdioStream::~StdioStream() {
- fclose((FILE *)_handle);
-}
-
-bool StdioStream::ioFailed() const {
- return ferror((FILE *)_handle) != 0;
-}
-
-void StdioStream::clearIOFailed() {
- clearerr((FILE *)_handle);
-}
-
-bool StdioStream::eos() const {
- return feof((FILE *)_handle) != 0;
-}
-
-uint32 StdioStream::pos() const {
- // FIXME: ftell can return -1 to indicate an error (in which case errno gets set)
- // Maybe we should support that, too?
- return ftell((FILE *)_handle);
-}
-
-uint32 StdioStream::size() const {
- uint32 oldPos = ftell((FILE *)_handle);
- fseek((FILE *)_handle, 0, SEEK_END);
- uint32 length = ftell((FILE *)_handle);
- fseek((FILE *)_handle, oldPos, SEEK_SET);
-
- return length;
-}
-
-void StdioStream::seek(int32 offs, int whence) {
- assert(_handle);
-
- if (fseek((FILE *)_handle, offs, whence) != 0)
- clearerr((FILE *)_handle); // FIXME: why do we call clearerr here?
-
- // FIXME: fseek has a return value to indicate errors;
- // Maybe we should support that, too?
-}
-
-uint32 StdioStream::read(void *ptr, uint32 len) {
- return (uint32)fread((byte *)ptr, 1, len, (FILE *)_handle);
-}
-
-uint32 StdioStream::write(const void *ptr, uint32 len) {
- return (uint32)fwrite(ptr, 1, len, (FILE *)_handle);
-}
-
-void StdioStream::flush() {
- // TODO: Should check the return value of fflush, and if it is non-zero,
- // check errno and set an error flag.
- fflush((FILE *)_handle);
-}
-
-
-
-
} // End of namespace Common
diff --git a/common/file.h b/common/file.h
index 6f18edbeb4..240835b5b9 100644
--- a/common/file.h
+++ b/common/file.h
@@ -154,29 +154,6 @@ public:
virtual void flush();
};
-
-class StdioStream : public SeekableReadStream, public WriteStream, public NonCopyable {
-protected:
- /** File handle to the actual file. */
- void *_handle;
-
-public:
- StdioStream(void *handle);
- virtual ~StdioStream();
-
- 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);
-};
-
} // End of namespace Common
#endif