aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Hoops2011-01-24 21:12:44 +0000
committerMatthew Hoops2011-01-24 21:12:44 +0000
commit45a4dfa44d595d3c81858b46f9896fdbf6ea02ad (patch)
treeb24d59de0f1d625986d9e05772de7499e77ade21
parent3e29897bb72da519c9ff4aa04488fcb0fe8ba131 (diff)
downloadscummvm-rg350-45a4dfa44d595d3c81858b46f9896fdbf6ea02ad.tar.gz
scummvm-rg350-45a4dfa44d595d3c81858b46f9896fdbf6ea02ad.tar.bz2
scummvm-rg350-45a4dfa44d595d3c81858b46f9896fdbf6ea02ad.zip
MOHAWK: Improve support for installer archives (partial directory support)
svn-id: r55506
-rw-r--r--engines/mohawk/installer_archive.cpp64
1 files changed, 49 insertions, 15 deletions
diff --git a/engines/mohawk/installer_archive.cpp b/engines/mohawk/installer_archive.cpp
index 8a486a2a58..560d99e121 100644
--- a/engines/mohawk/installer_archive.cpp
+++ b/engines/mohawk/installer_archive.cpp
@@ -40,6 +40,11 @@ InstallerArchive::~InstallerArchive() {
close();
}
+struct DirectoryEntry {
+ uint16 fileCount;
+ Common::String name;
+};
+
bool InstallerArchive::open(const Common::String &filename) {
close();
@@ -64,30 +69,59 @@ bool InstallerArchive::open(const Common::String &filename) {
uint16 fileCount = _stream->readUint16LE();
debug(2, "File count = %d", fileCount);
- for (uint16 i = 0; i < fileCount; i++) {
- FileEntry entry;
+ _stream->skip(9);
+
+ Common::Array<DirectoryEntry> directories;
+
+ for (uint16 i = 0; i < fileCount;) {
+ uint16 dirFileCount = _stream->readUint16LE();
+
+ if (dirFileCount == 0) {
+ // We've found a file
+ FileEntry entry;
+
+ _stream->skip(1); // Unknown
- _stream->skip(12); // Unknown
+ entry.uncompressedSize = _stream->readUint32LE();
+ entry.compressedSize = _stream->readUint32LE();
+ entry.offset = _stream->readUint32LE();
- entry.uncompressedSize = _stream->readUint32LE();
- entry.compressedSize = _stream->readUint32LE();
- entry.offset = _stream->readUint32LE();
+ _stream->skip(14); // Unknown
- _stream->skip(14); // Unknown
+ byte nameLength = _stream->readByte();
+ Common::String name;
+ while (nameLength--)
+ name += _stream->readByte();
- byte nameLength = _stream->readByte();
- Common::String name;
- while (nameLength--)
- name += _stream->readByte();
+ _stream->skip(13); // Unknown
- _stream->skip(4); // Unknown
+ _map[name] = entry;
+ i++;
- _map[name] = entry;
+ debug(3, "Found file '%s' at 0x%08x (Comp: 0x%08x, Uncomp: 0x%08x)", name.c_str(),
+ entry.offset, entry.compressedSize, entry.uncompressedSize);
+ } else {
+ // We've found a directory
+ DirectoryEntry dirEntry;
- debug(3, "Found file '%s' at 0x%08x (Comp: 0x%08x, Uncomp: 0x%08x)", name.c_str(),
- entry.offset, entry.compressedSize, entry.uncompressedSize);
+ dirEntry.fileCount = dirFileCount;
+ /* uint16 entrySize = */ _stream->readUint16LE();
+
+ uint16 nameLength = _stream->readUint16LE();
+ while (nameLength--)
+ dirEntry.name += _stream->readByte();
+
+ directories.push_back(dirEntry);
+
+ _stream->skip(5); // Unknown
+
+ debug(3, "Ignoring directory '%s'", dirEntry.name.c_str());
+ }
}
+ // TODO: Handle files in directories
+ // Per directory found follows DirectoryEntry::fileCount files
+
return true;
}