[Scummvm-cvs-logs] scummvm master -> dd347dec83e0d074585cdfd99aa93a17da94ccd4

bluegr bluegr at gmail.com
Sun Dec 28 15:58:06 CET 2014


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
dd347dec83 DEBUGGER: Extend the md5 and md5mac commands to handle any chunk length


Commit: dd347dec83e0d074585cdfd99aa93a17da94ccd4
    https://github.com/scummvm/scummvm/commit/dd347dec83e0d074585cdfd99aa93a17da94ccd4
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-12-28T16:57:00+02:00

Commit Message:
DEBUGGER: Extend the md5 and md5mac commands to handle any chunk length

This will be useful in matching the MD5 checksums with what the
advanced detector returns

Changed paths:
    gui/debugger.cpp



diff --git a/gui/debugger.cpp b/gui/debugger.cpp
index 216bd62..466681e 100644
--- a/gui/debugger.cpp
+++ b/gui/debugger.cpp
@@ -522,11 +522,25 @@ struct ArchiveMemberLess {
 
 bool Debugger::cmdMd5(int argc, const char **argv) {
 	if (argc < 2) {
-		debugPrintf("md5 <filename | pattern>\n");
+		debugPrintf("md5 [-n length] <filename | pattern>\n");
 	} else {
+		uint32 length = 0;
+		uint paramOffset = 0;
+
+		// If the user supplied an -n parameter, set the bytes to read
+		if (!strcmp(argv[1], "-n")) {
+			// Make sure that we have at least two more parameters
+			if (argc < 4) {
+				debugPrintf("md5 [-n length] <filename | pattern>\n");
+				return true;
+			}
+			length = atoi(argv[2]);
+			paramOffset = 2;
+		}
+		
 		// Assume that spaces are part of a single filename.
-		Common::String filename = argv[1];
-		for (int i = 2; i < argc; i++) {
+		Common::String filename = argv[1 + paramOffset];
+		for (int i = 2 + paramOffset; i < argc; i++) {
 			filename = filename + " " + argv[i];
 		}
 		Common::ArchiveMemberList list;
@@ -536,9 +550,9 @@ bool Debugger::cmdMd5(int argc, const char **argv) {
 		} else {
 			sort(list.begin(), list.end(), ArchiveMemberLess());
 			for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
-				Common::ReadStream *stream = (*iter)->createReadStream();
-				Common::String md5 = Common::computeStreamMD5AsString(*stream, 0);
-				debugPrintf("%s  %s\n", md5.c_str(), (*iter)->getDisplayName().c_str());
+				Common::SeekableReadStream *stream = (*iter)->createReadStream();
+				Common::String md5 = Common::computeStreamMD5AsString(*stream, length);
+				debugPrintf("%s  %s  %d\n", md5.c_str(), (*iter)->getDisplayName().c_str(), stream->size());
 				delete stream;
 			}
 		}
@@ -548,11 +562,25 @@ bool Debugger::cmdMd5(int argc, const char **argv) {
 
 bool Debugger::cmdMd5Mac(int argc, const char **argv) {
 	if (argc < 2) {
-		debugPrintf("md5mac <base filename>\n");
+		debugPrintf("md5mac [-n length] <base filename>\n");
 	} else {
+		uint32 length = 0;
+		uint paramOffset = 0;
+
+		// If the user supplied an -n parameter, set the bytes to read
+		if (!strcmp(argv[1], "-n")) {
+			// Make sure that we have at least two more parameters
+			if (argc < 4) {
+				debugPrintf("md5mac [-n length] <base filename>\n");
+				return true;
+			}
+			length = atoi(argv[2]);
+			paramOffset = 2;
+		}
+		
 		// Assume that spaces are part of a single filename.
-		Common::String filename = argv[1];
-		for (int i = 2; i < argc; i++) {
+		Common::String filename = argv[1 + paramOffset];
+		for (int i = 2 + paramOffset; i < argc; i++) {
 			filename = filename + " " + argv[i];
 		}
 		Common::MacResManager macResMan;
@@ -568,13 +596,13 @@ bool Debugger::cmdMd5Mac(int argc, const char **argv) {
 			} else {
 				// The resource fork is probably the most relevant one.
 				if (macResMan.hasResFork()) {
-					Common::String md5 = macResMan.computeResForkMD5AsString(0);
-					debugPrintf("%s  %s (resource)\n", md5.c_str(), macResMan.getBaseFileName().c_str());
+					Common::String md5 = macResMan.computeResForkMD5AsString(length);
+					debugPrintf("%s  %s (resource)  %d\n", md5.c_str(), macResMan.getBaseFileName().c_str(), macResMan.getResForkDataSize());
 				}
 				if (macResMan.hasDataFork()) {
-					Common::ReadStream *stream = macResMan.getDataFork();
-					Common::String md5 = Common::computeStreamMD5AsString(*stream, 0);
-					debugPrintf("%s  %s (data)\n", md5.c_str(), macResMan.getBaseFileName().c_str());
+					Common::SeekableReadStream *stream = macResMan.getDataFork();
+					Common::String md5 = Common::computeStreamMD5AsString(*stream, length);
+					debugPrintf("%s  %s (data)  %d\n", md5.c_str(), macResMan.getBaseFileName().c_str(), stream->size());
 				}
 			}
 			macResMan.close();






More information about the Scummvm-git-logs mailing list