aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/teenagent/pack.cpp13
-rw-r--r--engines/teenagent/pack.h5
2 files changed, 6 insertions, 12 deletions
diff --git a/engines/teenagent/pack.cpp b/engines/teenagent/pack.cpp
index c342ea7134..fa57256b3b 100644
--- a/engines/teenagent/pack.cpp
+++ b/engines/teenagent/pack.cpp
@@ -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]);
}
diff --git a/engines/teenagent/pack.h b/engines/teenagent/pack.h
index 53fdf80d33..753941673c 100644
--- a/engines/teenagent/pack.h
+++ b/engines/teenagent/pack.h
@@ -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;