2007-05-30 21:56:52 +00:00
|
|
|
/* 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.
|
2002-08-24 15:31:37 +00:00
|
|
|
*
|
|
|
|
* 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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-08-24 15:31:37 +00:00
|
|
|
*
|
2006-02-11 09:55:41 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2002-08-24 15:31:37 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-02-19 17:48:19 +00:00
|
|
|
#ifndef SCUMM_SMUSH_CHUNK_H
|
|
|
|
#define SCUMM_SMUSH_CHUNK_H
|
2002-08-24 15:31:37 +00:00
|
|
|
|
2003-03-17 12:28:50 +00:00
|
|
|
#include "common/scummsys.h"
|
2005-03-07 00:38:18 +00:00
|
|
|
#include "common/str.h"
|
2006-10-28 01:20:19 +00:00
|
|
|
#include "common/stream.h"
|
2002-08-24 15:31:37 +00:00
|
|
|
|
2003-10-03 18:33:57 +00:00
|
|
|
namespace Scumm {
|
|
|
|
|
2006-04-23 17:47:40 +00:00
|
|
|
class BaseScummFile;
|
2004-07-26 23:15:01 +00:00
|
|
|
|
2006-10-28 01:20:19 +00:00
|
|
|
class Chunk : public Common::SeekableReadStream {
|
2002-08-24 15:31:37 +00:00
|
|
|
public:
|
2003-03-17 12:28:50 +00:00
|
|
|
typedef uint32 type;
|
2006-10-28 01:20:19 +00:00
|
|
|
|
2003-03-17 12:28:50 +00:00
|
|
|
virtual type getType() const = 0;
|
|
|
|
virtual Chunk *subBlock() = 0;
|
2005-06-26 23:37:59 +00:00
|
|
|
virtual void reseek() = 0;
|
2002-08-24 15:31:37 +00:00
|
|
|
};
|
|
|
|
|
2003-05-25 11:39:08 +00:00
|
|
|
// Common functionality for concrete chunks (FileChunk, MemoryChunk)
|
|
|
|
class BaseChunk : public Chunk {
|
|
|
|
protected:
|
|
|
|
Chunk::type _type;
|
|
|
|
uint32 _size;
|
|
|
|
uint32 _curPos;
|
2006-05-18 00:20:53 +00:00
|
|
|
Common::String _name;
|
2003-05-25 11:39:08 +00:00
|
|
|
|
|
|
|
BaseChunk();
|
|
|
|
|
|
|
|
public:
|
|
|
|
Chunk::type getType() const;
|
2006-10-28 01:20:19 +00:00
|
|
|
uint32 size() const;
|
|
|
|
bool eos() const;
|
|
|
|
uint32 pos() const;
|
2006-10-28 01:28:41 +00:00
|
|
|
void seek(int32 delta, int dir);
|
2003-05-25 11:39:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class FileChunk : public BaseChunk {
|
2002-08-24 15:31:37 +00:00
|
|
|
private:
|
2006-04-23 17:47:40 +00:00
|
|
|
BaseScummFile *_data;
|
2005-06-26 23:37:59 +00:00
|
|
|
bool _deleteData;
|
2002-08-30 07:24:45 +00:00
|
|
|
uint32 _offset;
|
2003-03-17 12:28:50 +00:00
|
|
|
|
2006-04-23 17:47:40 +00:00
|
|
|
FileChunk(BaseScummFile *data, int offset);
|
2002-08-24 15:31:37 +00:00
|
|
|
public:
|
2005-03-07 00:38:18 +00:00
|
|
|
FileChunk(const Common::String &name, int offset = 0);
|
2002-08-24 17:18:55 +00:00
|
|
|
virtual ~FileChunk();
|
2003-03-17 12:28:50 +00:00
|
|
|
Chunk *subBlock();
|
2005-06-26 23:37:59 +00:00
|
|
|
void reseek();
|
2006-10-28 01:20:19 +00:00
|
|
|
uint32 read(void *buffer, uint32 size);
|
2002-08-24 15:31:37 +00:00
|
|
|
};
|
|
|
|
|
2003-05-25 11:39:08 +00:00
|
|
|
class MemoryChunk : public BaseChunk {
|
2002-08-24 15:31:37 +00:00
|
|
|
private:
|
2003-03-06 08:36:56 +00:00
|
|
|
byte *_data;
|
2003-03-17 12:28:50 +00:00
|
|
|
|
2002-08-24 15:31:37 +00:00
|
|
|
public:
|
2003-05-25 11:39:08 +00:00
|
|
|
MemoryChunk(byte *data);
|
2003-03-06 08:36:56 +00:00
|
|
|
Chunk *subBlock();
|
2005-06-26 23:37:59 +00:00
|
|
|
void reseek();
|
2006-10-28 01:20:19 +00:00
|
|
|
uint32 read(void *buffer, uint32 size);
|
2002-08-24 15:31:37 +00:00
|
|
|
};
|
|
|
|
|
2003-10-03 18:33:57 +00:00
|
|
|
} // End of namespace Scumm
|
|
|
|
|
2002-08-24 15:31:37 +00:00
|
|
|
#endif
|