[Scummvm-cvs-logs] SF.net SVN: scummvm:[52200] scummvm/trunk/engines/kyra/resource_intern.cpp
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Thu Aug 19 04:38:42 CEST 2010
Revision: 52200
http://scummvm.svn.sourceforge.net/scummvm/?rev=52200&view=rev
Author: lordhoto
Date: 2010-08-19 02:38:42 +0000 (Thu, 19 Aug 2010)
Log Message:
-----------
KYRA: Cleanup.
Modified Paths:
--------------
scummvm/trunk/engines/kyra/resource_intern.cpp
Modified: scummvm/trunk/engines/kyra/resource_intern.cpp
===================================================================
--- scummvm/trunk/engines/kyra/resource_intern.cpp 2010-08-18 21:58:58 UTC (rev 52199)
+++ scummvm/trunk/engines/kyra/resource_intern.cpp 2010-08-19 02:38:42 UTC (rev 52200)
@@ -142,6 +142,30 @@
return (filename.hasSuffix(".PAK") || filename.hasSuffix(".APK") || filename.hasSuffix(".VRM") || filename.hasSuffix(".CMP") || filename.hasSuffix(".TLK") || filename.equalsIgnoreCase(StaticResource::staticDataFilename()));
}
+namespace {
+
+Common::String readString(Common::SeekableReadStream &stream) {
+ Common::String result;
+ char c = 0;
+
+ while ((c = stream.readByte()) != 0)
+ result += c;
+
+ return result;
+}
+
+struct PlainArchiveListSearch {
+ PlainArchiveListSearch(const Common::String &search) : _search(search) {}
+
+ bool operator()(const PlainArchive::InputEntry &entry) {
+ return _search.equalsIgnoreCase(entry.name);
+ }
+
+ const Common::String _search;
+};
+
+} // end of anonymous namespace
+
bool ResLoaderPak::isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const {
int32 filesize = stream.size();
if (filesize < 0)
@@ -163,13 +187,8 @@
if (offset < stream.pos() || offset > filesize || offset < 0)
return false;
- byte c = 0;
+ file = readString(stream);
- file.clear();
-
- while (!stream.eos() && (c = stream.readByte()) != 0)
- file += c;
-
if (stream.eos())
return false;
@@ -191,29 +210,6 @@
return true;
}
-namespace {
-
-Common::String readString(Common::SeekableReadStream &stream) {
- Common::String result;
- char c = 0;
-
- while ((c = stream.readByte()) != 0)
- result += c;
-
- return result;
-}
-
-struct PlainArchiveListSearch {
- PlainArchiveListSearch(const Common::String &search) : _search(search) {}
-
- bool operator()(const PlainArchive::InputEntry &entry) {
- return _search.equalsIgnoreCase(entry.name);
- }
- Common::String _search;
-};
-
-} // end of anonymous namespace
-
Common::Archive *ResLoaderPak::load(Common::SharedPtr<Common::ArchiveMember> memberFile, Common::SeekableReadStream &stream) const {
int32 filesize = stream.size();
if (filesize < 0)
@@ -239,12 +235,8 @@
return 0;
}
- file.clear();
- byte c = 0;
+ file = readString(stream);
- while (!stream.eos() && (c = stream.readByte()) != 0)
- file += c;
-
if (stream.eos()) {
warning("PAK file '%s' is corrupted", memberFile->getDisplayName().c_str());
return 0;
@@ -423,11 +415,8 @@
uint32 resOffset = stream.readUint32LE();
entry.offset = resOffset+4;
+ entry.name = Common::String::printf("%.08u.AUD", resFilename);
- char realFilename[20];
- snprintf(realFilename, 20, "%.08u.AUD", resFilename);
- entry.name = realFilename;
-
uint32 curOffset = stream.pos();
stream.seek(resOffset, SEEK_SET);
entry.size = stream.readUint32LE();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list