DEBUGGER: Add "md5mac" command to get MD5 sum of Mac resource fork.

This commit is contained in:
Torbjörn Andersson 2014-09-01 21:19:48 +02:00
parent f1fae53731
commit 84548847a1
2 changed files with 28 additions and 0 deletions

View File

@ -30,6 +30,7 @@
#ifndef DISABLE_MD5
#include "common/md5.h"
#include "common/archive.h"
#include "common/macresman.h"
#include "common/stream.h"
#endif
@ -69,6 +70,7 @@ Debugger::Debugger() {
registerCmd("openlog", WRAP_METHOD(Debugger, cmdOpenLog));
#ifndef DISABLE_MD5
registerCmd("md5", WRAP_METHOD(Debugger, cmdMd5));
registerCmd("md5mac", WRAP_METHOD(Debugger, cmdMd5Mac));
#endif
registerCmd("debuglevel", WRAP_METHOD(Debugger, cmdDebugLevel));
@ -536,6 +538,31 @@ bool Debugger::cmdMd5(int argc, const char **argv) {
}
return true;
}
bool Debugger::cmdMd5Mac(int argc, const char **argv) {
if (argc < 2) {
debugPrintf("md5mac <filename>\n");
} else {
// Assume that spaces are part of a single filename.
Common::String filename = argv[1];
for (int i = 2; i < argc; i++) {
filename = filename + " " + argv[i];
}
Common::MacResManager macResMan;
if (!macResMan.open(filename)) {
debugPrintf("Resource file '%s' not found\n", filename.c_str());
} else {
Common::String md5 = macResMan.computeResForkMD5AsString(0);
if (md5.empty()) {
debugPrintf("'%s' has no resource fork\n", filename.c_str());
} else {
debugPrintf("%s %s\n", md5.c_str(), macResMan.getBaseFileName().c_str());
}
macResMan.close();
}
}
return true;
}
#endif
bool Debugger::cmdDebugLevel(int argc, const char **argv) {

View File

@ -215,6 +215,7 @@ protected:
bool cmdOpenLog(int argc, const char **argv);
#ifndef DISABLE_MD5
bool cmdMd5(int argc, const char **argv);
bool cmdMd5Mac(int argc, const char **argv);
#endif
bool cmdDebugLevel(int argc, const char **argv);
bool cmdDebugFlagsList(int argc, const char **argv);