diff options
| -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();  }; | 
