1 /* ScummVM Tools 2 * 3 * ScummVM Tools is the legal property of its developers, whose 4 * names are too numerous to list here. Please refer to the 5 * COPYRIGHT file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 */ 21 22 #ifndef EXTRACT_KYRA_H 23 #define EXTRACT_KYRA_H 24 25 #include <string.h> 26 27 #include "tool.h" 28 29 class ExtractKyra : public Tool { 30 public: 31 ExtractKyra(const std::string &name = "extract_kyra"); 32 33 virtual void execute(); 34 35 void parseExtraArguments(); 36 37 bool extractAll, extractOne, isAmiga, isHoFInstaller; 38 std::string singleFilename; 39 }; 40 41 42 class Extractor { 43 public: ~Extractor()44 virtual ~Extractor() {} 45 46 virtual void drawFileList(); 47 48 virtual bool outputAllFiles(Common::Filename *outputPath); 49 outputFile(const char * file)50 virtual bool outputFile(const char *file) { return outputFileAs(file, file); } 51 virtual bool outputFileAs(const char *file, const char *outputName); 52 53 struct FileList { FileListFileList54 FileList() : filename(0), size(0), data(0), next(0) {} ~FileListFileList55 ~FileList() { 56 delete[] filename; 57 delete[] data; 58 delete next; 59 } 60 findEntryFileList61 FileList *findEntry(const char *f) { 62 for (FileList *cur = this; cur; cur = cur->next) { 63 if (scumm_stricmp(cur->filename, f) == 0) 64 return cur; 65 } 66 return 0; 67 } 68 findEntryFileList69 const FileList *findEntry(const char *f) const { 70 for (const FileList *cur = this; cur; cur = cur->next) { 71 if (scumm_stricmp(cur->filename, f) == 0) 72 return cur; 73 } 74 return 0; 75 } 76 addEntryFileList77 void addEntry(FileList *e) { 78 if (next) 79 next->addEntry(e); 80 else 81 next = e; 82 } getTableSizeFileList83 uint32 getTableSize() const { 84 return strlen(filename)+1+4+((next != 0) ? next->getTableSize() : 0); 85 } getFileSizeFileList86 uint32 getFileSize() const { 87 return size + (next != 0 ? next->getFileSize() : 0); 88 } 89 90 char *filename; 91 uint32 size; 92 uint8 *data; 93 94 FileList *next; 95 }; 96 97 typedef const FileList cFileList; 98 99 virtual cFileList *getFileList() const = 0; 100 }; 101 102 #endif 103 104