aboutsummaryrefslogtreecommitdiff
path: root/backends/fs
diff options
context:
space:
mode:
authorMax Horn2010-07-05 19:10:20 +0000
committerMax Horn2010-07-05 19:10:20 +0000
commit68d620ccab1be965c8b0f7373cb1280e11244139 (patch)
tree8482080884fce3f4636d14e5d0da8d41d79f1ba0 /backends/fs
parent776c3a1d519838910732ab31b81b11cc5d122c88 (diff)
downloadscummvm-rg350-68d620ccab1be965c8b0f7373cb1280e11244139.tar.gz
scummvm-rg350-68d620ccab1be965c8b0f7373cb1280e11244139.tar.bz2
scummvm-rg350-68d620ccab1be965c8b0f7373cb1280e11244139.zip
DS: Fix warnings, make some vars static, cleanup
svn-id: r50701
Diffstat (limited to 'backends/fs')
-rw-r--r--backends/fs/ds/ds-fs.cpp16
-rw-r--r--backends/fs/ds/ds-fs.h4
2 files changed, 8 insertions, 12 deletions
diff --git a/backends/fs/ds/ds-fs.cpp b/backends/fs/ds/ds-fs.cpp
index fafdc8502e..43203eed54 100644
--- a/backends/fs/ds/ds-fs.cpp
+++ b/backends/fs/ds/ds-fs.cpp
@@ -416,18 +416,12 @@ bool DSFileStream::eos() const {
}
int32 DSFileStream::pos() const {
- if (_writeBufferPos > 0) {
- // Discard constness. Bad, but I can't see another way.
- ((DSFileStream *) (this))->flush();
- }
+ assert(_writeBufferPos == 0); // This method may only be called when reading!
return std_ftell((FILE *)_handle);
}
int32 DSFileStream::size() const {
- if (_writeBufferPos > 0) {
- // Discard constness. Bad, but I can't see another way.
- ((DSFileStream *) (this))->flush();
- }
+ assert(_writeBufferPos == 0); // This method may only be called when reading!
int32 oldPos = std_ftell((FILE *)_handle);
std_fseek((FILE *)_handle, 0, SEEK_END);
int32 length = std_ftell((FILE *)_handle);
@@ -659,10 +653,10 @@ size_t std_fread(void *ptr, size_t size, size_t numItems, FILE *handle) {
return bytes / size;
}
- if ((int)(handle->pos + size * numItems) > handle->size) {
+ if (handle->pos > handle->size)
+ numItems = 0;
+ else if ((int)(handle->pos + size * numItems) > handle->size)
numItems = (handle->size - handle->pos) / size;
- if (numItems < 0) numItems = 0;
- }
// consolePrintf("read %d ", size * numItems);
diff --git a/backends/fs/ds/ds-fs.h b/backends/fs/ds/ds-fs.h
index ee4afe60f3..fadfb8a40d 100644
--- a/backends/fs/ds/ds-fs.h
+++ b/backends/fs/ds/ds-fs.h
@@ -173,7 +173,9 @@ struct fileHandle {
class DSFileStream : public Common::SeekableReadStream, public Common::WriteStream, public Common::NonCopyable {
protected:
- static const int WRITE_BUFFER_SIZE = 512;
+ enum {
+ WRITE_BUFFER_SIZE = 512
+ };
/** File handle to the actual file. */
void *_handle;