svn-id: r4875
This commit is contained in:
Paweł Kołodziejski 2002-08-31 09:55:58 +00:00
parent 3826c7c8a8
commit e8c4f2099c
2 changed files with 24 additions and 18 deletions

View File

@ -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;
}

View File

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