diff options
Diffstat (limited to 'engines/scumm/smush/chunk.cpp')
-rw-r--r-- | engines/scumm/smush/chunk.cpp | 121 |
1 files changed, 0 insertions, 121 deletions
diff --git a/engines/scumm/smush/chunk.cpp b/engines/scumm/smush/chunk.cpp deleted file mode 100644 index aa7bb4a9df..0000000000 --- a/engines/scumm/smush/chunk.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - - -#include "scumm/smush/chunk.h" -#include "scumm/scumm.h" -#include "scumm/file.h" - -#include "common/file.h" -#include "common/str.h" -#include "common/util.h" - -namespace Scumm { - -bool Chunk::seek(int32 delta, int dir) { - switch (dir) { - case SEEK_CUR: - _curPos += delta; - break; - case SEEK_SET: - if (delta < 0) - error("invalid seek request"); - _curPos = (uint32)delta; - break; - case SEEK_END: - if (delta > 0 || _size < (uint32)-delta) - error("invalid seek request"); - _curPos = (uint32)(_size + delta); - break; - default: - break; - } - - if (_curPos > _size) { - // It may happen that user misused our SAN compression tool - // and ignored FLU index for videos which are used by INSANE. - // This will lead to incorrect seek requests - // - // In fact it may happen only within INSANE, so do not even check for it - warning("Looks like you compressed file %s in wrong way. It has FLU index which was not updated", _name.c_str()); - error("invalid seek request : %d > %d (delta == %d)", _curPos, _size, delta); - } - - return true; -} - -Chunk::Chunk(BaseScummFile *data, int offset) - : _type(0), _size(0), _curPos(0) { - _data = data; - _deleteData = false; - - _data->seek(offset, SEEK_SET); - _type = _data->readUint32BE(); - _size = _data->readUint32BE(); - _offset = _data->pos(); - _curPos = 0; -} - -Chunk::Chunk(const Common::String &name, int offset) - : _type(0), _size(0), _curPos(0) { - _data = new ScummFile(); - _deleteData = true; - if (!g_scumm->openFile(*_data, name)) - error("Chunk: Unable to open file %s", name.c_str()); - - _data->seek(offset, SEEK_SET); - _type = _data->readUint32BE(); - _size = _data->readUint32BE(); - _offset = _data->pos(); - _curPos = 0; - _name = name; -} - -Chunk::~Chunk() { - if (_deleteData) - delete _data; -} - -Chunk *Chunk::subBlock() { - Chunk *ptr = new Chunk(_data, _offset + _curPos); - skip(sizeof(Chunk::type) + sizeof(uint32) + ptr->size()); - return ptr; -} - -void Chunk::reseek() { - _data->seek(_offset + _curPos, SEEK_SET); -} - -uint32 Chunk::read(void *buffer, uint32 dataSize) { - if (dataSize <= 0 || (_curPos + dataSize) > _size) - error("invalid buffer read request"); - - dataSize = _data->read(buffer, dataSize); - _curPos += dataSize; - - return dataSize; -} - -} // End of namespace Scumm |