diff options
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) { |