diff options
Diffstat (limited to 'engines/cge/cfile.cpp')
-rw-r--r-- | engines/cge/cfile.cpp | 100 |
1 files changed, 2 insertions, 98 deletions
diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index c5c2c2c19c..f20ab16353 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -57,9 +57,6 @@ IoBuf::IoBuf(const char *name, IOMode mode, Crypt *crypt) IoBuf::~IoBuf() { debugC(6, kCGEDebugFile, "IoBuf::~IoBuf()"); - - if (_mode != kModeRead) - writeBuf(); free(_buff); } @@ -71,16 +68,6 @@ void IoBuf::readBuf() { _ptr = 0; } -void IoBuf::writeBuf() { - debugC(4, kCGEDebugFile, "IoBuf::writeBuf()"); - - if (_lim) { - IoHand::write(_buff, _lim); - _bufMark = IoHand::mark(); - _lim = 0; - } -} - uint16 IoBuf::read(void *buf, uint16 len) { debugC(4, kCGEDebugFile, "IoBuf::read(buf, %d)", len); @@ -149,45 +136,6 @@ uint16 IoBuf::read(uint8 *buf) { return total; } -uint16 IoBuf::write(void *buf, uint16 len) { - debugC(1, kCGEDebugFile, "IoBuf::write(buf, %d)", len); - - uint16 tot = 0; - while (len) { - uint16 n = kBufferSize - _lim; - if (n > len) - n = len; - if (n) { - memcpy(_buff + _lim, buf, n); - _lim += n; - len -= n; - buf = (uint8 *)buf + n; - tot += n; - } else - writeBuf(); - } - return tot; -} - -uint16 IoBuf::write(uint8 *buf) { - debugC(1, kCGEDebugFile, "IoBuf::write(buf)"); - - uint16 len = 0; - if (buf) { - len = strlen((const char *) buf); - if (len) - if (buf[len - 1] == '\n') - --len; - len = write(buf, len); - if (len) { - static char EOL[] = "\r\n"; - uint16 n = write(EOL, sizeof(EOL) - 1); - len += n; - } - } - return len; -} - int IoBuf::read() { debugC(1, kCGEDebugFile, "IoBuf::read()"); @@ -199,14 +147,6 @@ int IoBuf::read() { return _buff[_ptr++]; } -void IoBuf::write(uint8 b) { - debugC(1, kCGEDebugFile, "IoBuf::write(%d)", b); - - if (_lim >= kBufferSize) - writeBuf(); - _buff[_lim++] = b; -} - uint16 CFile::_maxLineLen = kLineMaxSize; CFile::CFile(const char *name, IOMode mode, Crypt *crypt) @@ -217,22 +157,6 @@ CFile::CFile(const char *name, IOMode mode, Crypt *crypt) CFile::~CFile() { } -void CFile::flush() { - debugC(1, kCGEDebugFile, "CFile::flush()"); - - if (_mode != kModeRead) - writeBuf(); - else - _lim = 0; - - /* - _BX = Handle; - _AH = 0x68; // Flush buffer - asm int 0x21 - */ - warning("FIXME: CFILE::Flush"); -} - long CFile::mark() { debugC(5, kCGEDebugFile, "CFile::mark()"); @@ -243,33 +167,13 @@ long CFile::seek(long pos) { debugC(1, kCGEDebugFile, "CFile::seek(%ld)", pos); if (pos >= _bufMark && pos < _bufMark + _lim) { - ((_mode == kModeRead) ? _ptr : _lim) = (uint16)(pos - _bufMark); + _ptr = (uint16)(pos - _bufMark); return pos; } else { - if (_mode != kModeRead) - writeBuf(); - else - _lim = 0; - + _lim = 0; _ptr = 0; return _bufMark = IoHand::seek(pos); } } -void CFile::append(CFile &f) { - debugC(1, kCGEDebugFile, "CFile::append(f)"); - - seek(size()); - if (f._error == 0) { - while (true) { - if ((_lim = f.IoHand::read(_buff, kBufferSize)) == kBufferSize) - writeBuf(); - else - break; - if ((_error = f._error) != 0) - break; - } - } -} - } // End of namespace CGE |