diff options
author | Johannes Schickel | 2008-02-09 15:18:35 +0000 |
---|---|---|
committer | Johannes Schickel | 2008-02-09 15:18:35 +0000 |
commit | 15f798d48a9a6a4903b8db73eedbcbfdb61dcf85 (patch) | |
tree | eb82b8862db74a77e98af59f2d866e8480c47e68 /engines/kyra/resource.cpp | |
parent | b3bab9afb9c531cf2b8431789200cc5b58afff39 (diff) | |
download | scummvm-rg350-15f798d48a9a6a4903b8db73eedbcbfdb61dcf85.tar.gz scummvm-rg350-15f798d48a9a6a4903b8db73eedbcbfdb61dcf85.tar.bz2 scummvm-rg350-15f798d48a9a6a4903b8db73eedbcbfdb61dcf85.zip |
Added filename check before header check when trying to detect archives types, this should lower the file i/o need a lot when starting up kyra2.
svn-id: r30835
Diffstat (limited to 'engines/kyra/resource.cpp')
-rw-r--r-- | engines/kyra/resource.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/engines/kyra/resource.cpp b/engines/kyra/resource.cpp index 112011cf5a..049c51727e 100644 --- a/engines/kyra/resource.cpp +++ b/engines/kyra/resource.cpp @@ -355,17 +355,23 @@ void Resource::detectFileTypes() { continue; if (i->_value.type == ResFileEntry::kAutoDetect) { + Common::SeekableReadStream *stream = 0; for (LoaderIterator l = _loaders.begin(); l != _loaders.end(); ++l) { - Common::SeekableReadStream *stream = getFileStream(i->_key); + if (!(*l)->checkFilename(i->_key)) + continue; + + if (!stream) + stream = getFileStream(i->_key); + if ((*l)->isLoadable(i->_key, *stream)) { i->_value.type = (*l)->getType(); i->_value.loadable = false; i->_value.preload = false; break; } - delete stream; - stream = 0; } + delete stream; + stream = 0; if (i->_value.type == ResFileEntry::kAutoDetect) { i->_value.type = ResFileEntry::kRaw; @@ -381,6 +387,7 @@ void Resource::detectFileTypes() { class ResLoaderPak : public ResArchiveLoader { public: + bool checkFilename(Common::String filename) const; bool isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const; bool loadFile(const Common::String &filename, Common::SeekableReadStream &stream, ResFileMap &map) const; Common::SeekableReadStream *loadFileFromArchive(const Common::String &file, Common::SeekableReadStream *archive, const ResFileMap &map) const; @@ -390,6 +397,11 @@ public: } }; +bool ResLoaderPak::checkFilename(Common::String filename) const { + filename.toUppercase(); + return (filename.hasSuffix(".PAK") || filename.hasSuffix(".APK") || filename.hasSuffix(".VRM") || filename.hasSuffix(".TLK") || filename.equalsIgnoreCase(StaticResource::staticDataFilename())); +} + bool ResLoaderPak::isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const { uint32 filesize = stream.size(); uint32 offset = 0; @@ -530,6 +542,7 @@ Common::SeekableReadStream *ResLoaderPak::loadFileFromArchive(const Common::Stri class ResLoaderIns : public ResArchiveLoader { public: + bool checkFilename(Common::String filename) const; bool isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const; bool loadFile(const Common::String &filename, Common::SeekableReadStream &stream, ResFileMap &map) const; Common::SeekableReadStream *loadFileFromArchive(const Common::String &file, Common::SeekableReadStream *archive, const ResFileMap &map) const; @@ -539,6 +552,11 @@ public: } }; +bool ResLoaderIns::checkFilename(Common::String filename) const { + filename.toUppercase(); + return (filename.hasSuffix(".001")); +} + bool ResLoaderIns::isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const { stream.seek(3); uint32 size = stream.readUint32LE(); |