diff options
author | Paweł Kołodziejski | 2002-08-31 09:55:58 +0000 |
---|---|---|
committer | Paweł Kołodziejski | 2002-08-31 09:55:58 +0000 |
commit | e8c4f2099c3b19c7f5b7395a2989419ae73f4ed0 (patch) | |
tree | bf4327b6dbf9d5d7b5836e590912cd51167c0c9f /common | |
parent | 3826c7c8a8fabf2bc0379de53b835b25adfa45c5 (diff) | |
download | scummvm-rg350-e8c4f2099c3b19c7f5b7395a2989419ae73f4ed0.tar.gz scummvm-rg350-e8c4f2099c3b19c7f5b7395a2989419ae73f4ed0.tar.bz2 scummvm-rg350-e8c4f2099c3b19c7f5b7395a2989419ae73f4ed0.zip |
updated
svn-id: r4875
Diffstat (limited to 'common')
-rw-r--r-- | common/file.cpp | 31 | ||||
-rw-r--r-- | common/file.h | 11 |
2 files changed, 24 insertions, 18 deletions
diff --git a/common/file.cpp b/common/file.cpp index edb7ad997e..a5c1608210 100644 --- a/common/file.cpp +++ b/common/file.cpp @@ -77,6 +77,11 @@ bool File::open(const char *filename, int mode, byte encbyte) { void File::close() { if (_handle) fclose(_handle); + _handle = NULL; +} + +bool File::isOpen() { + return _handle != NULL; } bool File::readFailed() { @@ -136,7 +141,7 @@ void File::read(void *ptr, uint32 size) { } while (--size); } -byte File::fileReadByte() { +byte File::readByte() { byte b; if (fread(&b, 1, 1, _handle) != 1) { @@ -146,26 +151,26 @@ byte File::fileReadByte() { return b ^ _encbyte; } -uint16 File::fileReadWordLE() { - uint a = fileReadByte(); - uint b = fileReadByte(); +uint16 File::readWordLE() { + uint16 a = readByte(); + uint16 b = readByte(); return a | (b << 8); } -uint32 File::fileReadDwordLE() { - uint a = fileReadWordLE(); - uint b = fileReadWordLE(); +uint32 File::readDwordLE() { + uint32 a = readWordLE(); + uint32 b = readWordLE(); return (b << 16) | a; } -uint16 File::fileReadWordBE() { - uint b = fileReadByte(); - uint a = fileReadByte(); +uint16 File::readWordBE() { + uint16 b = readByte(); + uint16 a = readByte(); return a | (b << 8); } -uint32 File::fileReadDwordBE() { - uint b = fileReadWordBE(); - uint a = fileReadWordBE(); +uint32 File::readDwordBE() { + uint32 b = readWordBE(); + uint32 a = readWordBE(); return (b << 16) | a; } diff --git a/common/file.h b/common/file.h index ea57aa9859..a3cb1988cc 100644 --- a/common/file.h +++ b/common/file.h @@ -40,17 +40,18 @@ public: ~File(); bool open(const char *filename, int mode = 1, byte encbyte = 0); void close(); + bool isOpen(); bool readFailed(); void clearReadFailed(); bool eof(); uint32 pos(); void seek(uint32 offs, int whence); void read(void *ptr, uint32 size); - byte fileReadByte(); - uint16 fileReadWordLE(); - uint32 fileReadDwordLE(); - uint16 fileReadWordBE(); - uint32 fileReadDwordBE(); + byte readByte(); + uint16 readWordLE(); + uint32 readDwordLE(); + uint16 readWordBE(); + uint32 readDwordBE(); }; |