diff options
author | Max Horn | 2008-09-13 16:51:46 +0000 |
---|---|---|
committer | Max Horn | 2008-09-13 16:51:46 +0000 |
commit | 655ce26b3f09628d9408a4d82efe3a26116999fe (patch) | |
tree | 779a25dbe25c8f916fb385b3dd2d48e0e379d9ec /backends/fs/stdiostream.cpp | |
parent | b86a047164b54c20366fcbe21b55bf63f2ced5f4 (diff) | |
download | scummvm-rg350-655ce26b3f09628d9408a4d82efe3a26116999fe.tar.gz scummvm-rg350-655ce26b3f09628d9408a4d82efe3a26116999fe.tar.bz2 scummvm-rg350-655ce26b3f09628d9408a4d82efe3a26116999fe.zip |
Big patch changing the signature of various Stream methods (some ports may need to be slightly tweaked to fix overloading errors/warnings)
svn-id: r34514
Diffstat (limited to 'backends/fs/stdiostream.cpp')
-rw-r--r-- | backends/fs/stdiostream.cpp | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/backends/fs/stdiostream.cpp b/backends/fs/stdiostream.cpp index f3f20eacb5..fafcca989b 100644 --- a/backends/fs/stdiostream.cpp +++ b/backends/fs/stdiostream.cpp @@ -126,43 +126,33 @@ 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? +int32 StdioStream::pos() const { return ftell((FILE *)_handle); } -uint32 StdioStream::size() const { - uint32 oldPos = ftell((FILE *)_handle); +int32 StdioStream::size() const { + int32 oldPos = ftell((FILE *)_handle); fseek((FILE *)_handle, 0, SEEK_END); - uint32 length = ftell((FILE *)_handle); + int32 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? +bool StdioStream::seek(int32 offs, int whence) { + return fseek((FILE *)_handle, offs, whence) == 0; } uint32 StdioStream::read(void *ptr, uint32 len) { - return (uint32)fread((byte *)ptr, 1, len, (FILE *)_handle); + return fread((byte *)ptr, 1, len, (FILE *)_handle); } uint32 StdioStream::write(const void *ptr, uint32 len) { - return (uint32)fwrite(ptr, 1, len, (FILE *)_handle); + return 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); +bool StdioStream::flush() { + return fflush((FILE *)_handle) == 0; } StdioStream *StdioStream::makeFromPath(const Common::String &path, bool writeMode) { |