diff options
author | Johannes Schickel | 2008-11-01 12:49:29 +0000 |
---|---|---|
committer | Johannes Schickel | 2008-11-01 12:49:29 +0000 |
commit | 282ebbb0e54211a1a3cef5510287a7c494fce1d2 (patch) | |
tree | 5e64df5b67a4bd44161deffde232fcb537511c34 /engines | |
parent | cd3011e4088fc25846278d2e8cf6527245d5d333 (diff) | |
download | scummvm-rg350-282ebbb0e54211a1a3cef5510287a7c494fce1d2.tar.gz scummvm-rg350-282ebbb0e54211a1a3cef5510287a7c494fce1d2.tar.bz2 scummvm-rg350-282ebbb0e54211a1a3cef5510287a7c494fce1d2.zip |
Commit of patch #2207782 "ARCHIVE: New method 'getMember'".
svn-id: r34871
Diffstat (limited to 'engines')
-rw-r--r-- | engines/kyra/resource.cpp | 19 | ||||
-rw-r--r-- | engines/kyra/resource_intern.cpp | 14 | ||||
-rw-r--r-- | engines/kyra/resource_intern.h | 2 |
3 files changed, 25 insertions, 10 deletions
diff --git a/engines/kyra/resource.cpp b/engines/kyra/resource.cpp index 2b09036b4e..d4b468fed5 100644 --- a/engines/kyra/resource.cpp +++ b/engines/kyra/resource.cpp @@ -107,15 +107,15 @@ bool Resource::reset() { }; for (uint i = 0; i < ARRAYSIZE(list); ++i) { - Common::ArchiveMemberList fileList; - listFiles(list[i], fileList); + Common::ArchiveMemberPtr file = _files.getMember(list[i]); + if (!file) + error("Couldn't find PAK file '%s'", list[i]); - if (fileList.empty()) - error("Couldn't load PAK file '%s'", list[i]); - - Common::Archive *archive = loadArchive(list[i], *fileList.begin()); + Common::Archive *archive = loadArchive(list[i], file); if (archive) _protectedFiles.add(list[i], archive, 0, false); + else + error("Couldn't load PAK file '%s'", list[i]); } } else { for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) { @@ -142,13 +142,12 @@ bool Resource::reset() { bool Resource::loadPakFile(Common::String filename) { filename.toUppercase(); - Common::ArchiveMemberList list; - _files.listMatchingMembers(list, filename); - if (list.empty()) + Common::ArchiveMemberPtr file = _files.getMember(filename); + if (!file) return false; - return loadPakFile(filename, *list.begin()); + return loadPakFile(filename, file); } bool Resource::loadPakFile(Common::String name, Common::SharedPtr<Common::ArchiveMember> file) { diff --git a/engines/kyra/resource_intern.cpp b/engines/kyra/resource_intern.cpp index fbbfe69186..cbb6dc4f0c 100644 --- a/engines/kyra/resource_intern.cpp +++ b/engines/kyra/resource_intern.cpp @@ -62,6 +62,13 @@ int PlainArchive::listMembers(Common::ArchiveMemberList &list) { return count; } +Common::ArchiveMemberPtr PlainArchive::getMember(const Common::String &name) { + if (!hasFile(name)) + return Common::ArchiveMemberPtr(); + + return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this)); +} + Common::SeekableReadStream *PlainArchive::openFile(const Common::String &name) { FileMap::const_iterator fDesc = _files.find(name); if (fDesc == _files.end()) @@ -110,6 +117,13 @@ int CachedArchive::listMembers(Common::ArchiveMemberList &list) { return count; } +Common::ArchiveMemberPtr CachedArchive::getMember(const Common::String &name) { + if (!hasFile(name)) + return Common::ArchiveMemberPtr(); + + return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this)); +} + Common::SeekableReadStream *CachedArchive::openFile(const Common::String &name) { FileMap::const_iterator fDesc = _files.find(name); if (fDesc == _files.end()) diff --git a/engines/kyra/resource_intern.h b/engines/kyra/resource_intern.h index 6347c538fc..f768100afe 100644 --- a/engines/kyra/resource_intern.h +++ b/engines/kyra/resource_intern.h @@ -51,6 +51,7 @@ public: bool hasFile(const Common::String &name); int listMembers(Common::ArchiveMemberList &list); + Common::ArchiveMemberPtr getMember(const Common::String &name); Common::SeekableReadStream *openFile(const Common::String &name); private: struct Entry { @@ -80,6 +81,7 @@ public: bool hasFile(const Common::String &name); int listMembers(Common::ArchiveMemberList &list); + Common::ArchiveMemberPtr getMember(const Common::String &name); Common::SeekableReadStream *openFile(const Common::String &name); private: struct Entry { |