diff options
author | Filippos Karapetis | 2014-12-21 23:33:01 +0200 |
---|---|---|
committer | Filippos Karapetis | 2014-12-21 23:33:01 +0200 |
commit | 965dafe31b1c1f7c4684c0d2cbdb3461e3fddac8 (patch) | |
tree | 8615216939eeb56d9a21d99290dbcf000900e20d /engines | |
parent | e34b5be8e3d4842e273f08821b6a7bd7ba65e843 (diff) | |
download | scummvm-rg350-965dafe31b1c1f7c4684c0d2cbdb3461e3fddac8.tar.gz scummvm-rg350-965dafe31b1c1f7c4684c0d2cbdb3461e3fddac8.tar.bz2 scummvm-rg350-965dafe31b1c1f7c4684c0d2cbdb3461e3fddac8.zip |
ZVISION: Implement the "dumpallscripts" console command again
Diffstat (limited to 'engines')
-rw-r--r-- | engines/zvision/core/console.cpp | 40 | ||||
-rw-r--r-- | engines/zvision/core/console.h | 1 | ||||
-rw-r--r-- | engines/zvision/file/search_manager.cpp | 7 | ||||
-rw-r--r-- | engines/zvision/file/search_manager.h | 18 |
4 files changed, 48 insertions, 18 deletions
diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index 4dd10d6f40..0789f8d4fb 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -52,6 +52,7 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) { registerCmd("setpanoramascale", WRAP_METHOD(Console, cmdSetPanoramaScale)); registerCmd("location", WRAP_METHOD(Console, cmdLocation)); registerCmd("dumpfile", WRAP_METHOD(Console, cmdDumpFile)); + registerCmd("dumpallscripts", WRAP_METHOD(Console, cmdDumpAllScripts)); } bool Console::cmdLoadVideo(int argc, const char **argv) { @@ -205,6 +206,20 @@ bool Console::cmdLocation(int argc, const char **argv) { return true; } +void dumpFile(Common::SeekableReadStream *s, const char *outName) { + byte *buffer = new byte[s->size()]; + s->read(buffer, s->size()); + + Common::DumpFile dumpFile; + dumpFile.open(outName); + + dumpFile.write(buffer, s->size()); + dumpFile.flush(); + dumpFile.close(); + + delete[] buffer; +} + bool Console::cmdDumpFile(int argc, const char **argv) { if (argc != 2) { debugPrintf("Use %s <fileName> to dump a file\n", argv[0]); @@ -217,17 +232,26 @@ bool Console::cmdDumpFile(int argc, const char **argv) { return true; } - byte *buffer = new byte[f.size()]; - f.read(buffer, f.size()); + dumpFile(&f, argv[1]); - Common::DumpFile dumpFile; - dumpFile.open(argv[1]); + return true; +} - dumpFile.write(buffer, f.size()); - dumpFile.flush(); - dumpFile.close(); +bool Console::cmdDumpAllScripts(int argc, const char **argv) { + Common::String fileName; + Common::SeekableReadStream *in; - delete[] buffer; + SearchManager::MatchList fileList; + _engine->getSearchManager()->listMembersWithExtension(fileList, "scr"); + + for (SearchManager::MatchList::iterator iter = fileList.begin(); iter != fileList.end(); ++iter) { + fileName = iter->_value.name; + debugPrintf("Dumping %s\n", fileName.c_str()); + + in = iter->_value.arch->createReadStreamForMember(iter->_value.name); + dumpFile(in, fileName.c_str()); + delete in; + } return true; } diff --git a/engines/zvision/core/console.h b/engines/zvision/core/console.h index 299bd6127f..7e27fe8f26 100644 --- a/engines/zvision/core/console.h +++ b/engines/zvision/core/console.h @@ -46,6 +46,7 @@ private: bool cmdSetPanoramaScale(int argc, const char **argv); bool cmdLocation(int argc, const char **argv); bool cmdDumpFile(int argc, const char **argv); + bool cmdDumpAllScripts(int argc, const char **argv); }; } // End of namespace ZVision diff --git a/engines/zvision/file/search_manager.cpp b/engines/zvision/file/search_manager.cpp index d0d4e43d12..7a907df39c 100644 --- a/engines/zvision/file/search_manager.cpp +++ b/engines/zvision/file/search_manager.cpp @@ -275,4 +275,11 @@ void SearchManager::listDirRecursive(Common::List<Common::String> &_list, const } } +void SearchManager::listMembersWithExtension(MatchList &fileList, Common::String extension) { + for (SearchManager::MatchList::iterator it = _files.begin(); it != _files.end(); ++it) { + if (it->_key.hasSuffix(extension)) + fileList[it->_key] = it->_value; + } +} + } // End of namespace ZVision diff --git a/engines/zvision/file/search_manager.h b/engines/zvision/file/search_manager.h index fdd70fd381..b9ed02ec13 100644 --- a/engines/zvision/file/search_manager.h +++ b/engines/zvision/file/search_manager.h @@ -47,25 +47,23 @@ public: void loadZix(const Common::String &name); -private: - - void listDirRecursive(Common::List<Common::String> &dirList, const Common::FSNode &fsNode, int depth); - struct Node { Common::String name; Common::Archive *arch; }; - Common::List<Common::String> _dirList; - typedef Common::HashMap<Common::String, Node, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> MatchList; - Common::List<Common::Archive *> _archList; - MatchList _files; - - Common::String _root; + void listMembersWithExtension(MatchList &fileList, Common::String extension); private: + + void listDirRecursive(Common::List<Common::String> &dirList, const Common::FSNode &fsNode, int depth); + + Common::List<Common::String> _dirList; + Common::List<Common::Archive *> _archList; + Common::String _root; + MatchList _files; }; } |