diff options
author | Strangerke | 2011-09-13 00:07:00 +0200 |
---|---|---|
committer | Strangerke | 2011-09-13 00:07:00 +0200 |
commit | 5d8bbc2f48a5c736fbeeb42b31b3fa6e453cc5e1 (patch) | |
tree | 5920c953a2316f7e135fb57b418178a716e498ba /engines/cge/fileio.cpp | |
parent | 7624cc382210d364dbcf3fab2c782d5cd0b121a3 (diff) | |
download | scummvm-rg350-5d8bbc2f48a5c736fbeeb42b31b3fa6e453cc5e1.tar.gz scummvm-rg350-5d8bbc2f48a5c736fbeeb42b31b3fa6e453cc5e1.tar.bz2 scummvm-rg350-5d8bbc2f48a5c736fbeeb42b31b3fa6e453cc5e1.zip |
CGE: Remove IoBuf and CFile
Diffstat (limited to 'engines/cge/fileio.cpp')
-rw-r--r-- | engines/cge/fileio.cpp | 146 |
1 files changed, 0 insertions, 146 deletions
diff --git a/engines/cge/fileio.cpp b/engines/cge/fileio.cpp index 888437c18c..5c63d41ff2 100644 --- a/engines/cge/fileio.cpp +++ b/engines/cge/fileio.cpp @@ -79,152 +79,6 @@ long IoHand::size() { } /*----------------------------------------------------------------------- - * IoBuf - *-----------------------------------------------------------------------*/ -IoBuf::IoBuf(Crypt *crypt) - : IoHand(crypt), - _bufMark(0), - _ptr(0), - _lim(0) { - debugC(1, kCGEDebugFile, "IoBuf::IoBuf(crypt)"); - - _buff = (uint8 *)malloc(sizeof(uint8) * kBufferSize); - assert(_buff != NULL); -} - -IoBuf::IoBuf(const char *name, Crypt *crypt) - : IoHand(name, crypt), - _bufMark(0), - _ptr(0), - _lim(0) { - debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%s, crypt)", name); - - _buff = (uint8 *)malloc(sizeof(uint8) * kBufferSize); - assert(_buff != NULL); -} - -IoBuf::~IoBuf() { - debugC(6, kCGEDebugFile, "IoBuf::~IoBuf()"); - free(_buff); -} - -void IoBuf::readBuf() { - debugC(4, kCGEDebugFile, "IoBuf::readBuf()"); - - _bufMark = IoHand::mark(); - _lim = IoHand::read(_buff, kBufferSize); - _ptr = 0; -} - -uint16 IoBuf::read(void *buf, uint16 len) { - debugC(4, kCGEDebugFile, "IoBuf::read(buf, %d)", len); - - uint16 total = 0; - while (len) { - if (_ptr >= _lim) - readBuf(); - uint16 n = _lim - _ptr; - if (n) { - if (len < n) - n = len; - memcpy(buf, _buff + _ptr, n); - buf = (uint8 *)buf + n; - len -= n; - total += n; - _ptr += n; - } else - break; - } - return total; -} - -uint16 IoBuf::read(uint8 *buf) { - debugC(3, kCGEDebugFile, "IoBuf::read(buf)"); - - uint16 total = 0; - - while (total < kLineMaxSize - 2) { - if (_ptr >= _lim) - readBuf(); - uint8 *p = _buff + _ptr; - uint16 n = _lim - _ptr; - if (n) { - if (total + n >= kLineMaxSize - 2) - n = kLineMaxSize - 2 - total; - uint8 *eol = (uint8 *) memchr(p, '\r', n); - if (eol) - n = (uint16)(eol - p); - uint8 *eof = (uint8 *) memchr(p, '\32', n); - if (eof) { // end-of-file - n = (uint16)(eof - p); - _ptr = (uint16)(eof - _buff); - } - if (n) - memcpy(buf, p, n); - buf += n; - total += n; - if (eof) - break; - _ptr += n; - if (eol) { - _ptr++; - *(buf++) = '\n'; - total++; - if (_ptr >= _lim) - readBuf(); - if (_ptr < _lim) - if (_buff[_ptr] == '\n') - ++_ptr; - break; - } - } else - break; - } - *buf = '\0'; - return total; -} - -int IoBuf::read() { - debugC(1, kCGEDebugFile, "IoBuf::read()"); - - if (_ptr >= _lim) { - readBuf(); - if (_lim == 0) - return -1; - } - return _buff[_ptr++]; -} - -/*----------------------------------------------------------------------- - * CFile - *-----------------------------------------------------------------------*/ -CFile::CFile(const char *name, Crypt *crypt) : IoBuf(name, crypt) { - debugC(1, kCGEDebugFile, "CFile::CFile(%s, crypt)", name); -} - -CFile::~CFile() { -} - -long CFile::mark() { - debugC(5, kCGEDebugFile, "CFile::mark()"); - - return _bufMark + _ptr; -} - -long CFile::seek(long pos) { - debugC(1, kCGEDebugFile, "CFile::seek(%ld)", pos); - - if (pos >= _bufMark && pos < _bufMark + _lim) { - _ptr = (uint16)(pos - _bufMark); - return pos; - } else { - _lim = 0; - _ptr = 0; - return _bufMark = IoHand::seek(pos); - } -} - -/*----------------------------------------------------------------------- * BtPage *-----------------------------------------------------------------------*/ void BtPage::read(Common::ReadStream &s) { |