SHERLOCK: Implement the "dumpfile" debugger command

This can help us debug resources bundled within LIB files
This commit is contained in:
Filippos Karapetis 2015-06-07 20:34:02 +03:00
parent 47d905486c
commit 0f8f40c111
2 changed files with 35 additions and 0 deletions

View File

@ -39,6 +39,7 @@ Debugger::Debugger(SherlockEngine *vm) : GUI::Debugger(), _vm(vm) {
registerCmd("3do_playmovie", WRAP_METHOD(Debugger, cmd3DO_PlayMovie));
registerCmd("3do_playaudio", WRAP_METHOD(Debugger, cmd3DO_PlayAudio));
registerCmd("song", WRAP_METHOD(Debugger, cmdSong));
registerCmd("dumpfile", WRAP_METHOD(Debugger, cmdDumpFile));
}
void Debugger::postEnter() {
@ -140,4 +141,33 @@ bool Debugger::cmdSong(int argc, const char **argv) {
return false;
}
bool Debugger::cmdDumpFile(int argc, const char **argv) {
if (argc != 2) {
debugPrintf("Format: dumpfile <resource name>\n");
return true;
}
Common::SeekableReadStream *s = _vm->_res->load(argv[1]);
if (!s) {
debugPrintf("Invalid resource.\n");
return true;
}
byte *buffer = new byte[s->size()];
s->read(buffer, s->size());
Common::DumpFile dumpFile;
dumpFile.open(argv[1]);
dumpFile.write(buffer, s->size());
dumpFile.flush();
dumpFile.close();
delete[] buffer;
debugPrintf("Resource %s has been dumped to disk.\n", argv[1]);
return true;
}
} // End of namespace Sherlock

View File

@ -65,6 +65,11 @@ private:
*/
bool cmdSong(int argc, const char **argv);
/**
* Dumps a file to disk
*/
bool cmdDumpFile(int argc, const char **argv);
private:
Common::String _3doPlayMovieFile;
};