documented pack classes, restored old substream creation for FilePack

svn-id: r48324
This commit is contained in:
Vladimir Menshakov 2010-03-20 16:08:28 +00:00
parent 6fb96d7e90
commit a61e36dcd2
2 changed files with 6 additions and 12 deletions

View File

@ -49,12 +49,7 @@ bool FilePack::open(const Common::String &filename) {
offsets = new uint32[_fileCount + 1];
for (uint32 i = 0; i <= _fileCount; ++i) {
offsets[i] = file.readUint32LE();
//debug(0, "%d: %06x", i, offsets[i]);
}
/* for (uint32 i = 0; i < count; ++i) {
debug(0, "%d: len = %d", i, offsets[i + 1] - offsets[i]);
}
*/
return true;
}
@ -79,13 +74,7 @@ Common::SeekableReadStream *FilePack::getStream(uint32 id) const {
if (id < 1 || id > _fileCount)
return NULL;
//debug(0, "stream: %04x-%04x", offsets[id - 1], offsets[id]);
file.seek(offsets[id - 1]);
uint32 size = offsets[id] - offsets[id - 1];
byte *ptr = (byte *)malloc(size);
if (ptr == NULL)
return NULL;
uint32 r = file.read(ptr, size);
return new Common::MemoryReadStream(ptr, r, DisposeAfterUse::YES);
return new Common::SeekableSubReadStream(&file, offsets[id - 1], offsets[id]);
}

View File

@ -46,6 +46,7 @@ public:
virtual Common::SeekableReadStream *getStream(uint32 id) const = 0;
};
///FilePack keeps opened file and returns substream for each request.
class FilePack : public Pack {
mutable Common::File file;
uint32 *offsets;
@ -62,6 +63,9 @@ public:
virtual Common::SeekableReadStream *getStream(uint32 id) const;
};
/** Pack file which reopens file each request. Do not keep file descriptor open.
** Useful for minimizing file descriptors opened at the same time. Critical for PSP backend.
**/
class TransientFilePack : public Pack {
uint32 *offsets;
Common::String _filename;
@ -78,6 +82,7 @@ public:
virtual Common::SeekableReadStream *getStream(uint32 id) const;
};
///MemoryPack loads whole pack in memory, currently unused.
class MemoryPack : public Pack {
struct Chunk {
byte *data;