aboutsummaryrefslogtreecommitdiff
path: root/devtools/create_kyradat/pak.h
diff options
context:
space:
mode:
authorMax Horn2011-04-09 23:47:35 +0200
committerMax Horn2011-04-09 23:47:35 +0200
commit6cf1de87acdb878e3a3e4ef7cc33d45adee4a592 (patch)
treed20295fc02d514a62ee4f22a5a34136316d0916c /devtools/create_kyradat/pak.h
parentae49865e9e48b8569922d2ea1792541fb23b4a64 (diff)
downloadscummvm-rg350-6cf1de87acdb878e3a3e4ef7cc33d45adee4a592.tar.gz
scummvm-rg350-6cf1de87acdb878e3a3e4ef7cc33d45adee4a592.tar.bz2
scummvm-rg350-6cf1de87acdb878e3a3e4ef7cc33d45adee4a592.zip
DEVTOOLS: Renamed 'tools' directory to 'devtools'
Diffstat (limited to 'devtools/create_kyradat/pak.h')
-rw-r--r--devtools/create_kyradat/pak.h110
1 files changed, 110 insertions, 0 deletions
diff --git a/devtools/create_kyradat/pak.h b/devtools/create_kyradat/pak.h
new file mode 100644
index 0000000000..ee6dabb672
--- /dev/null
+++ b/devtools/create_kyradat/pak.h
@@ -0,0 +1,110 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef KYRA_PAK_H
+#define KYRA_PAK_H
+
+#include "util.h"
+#include <string.h>
+
+class PAKFile {
+public:
+ PAKFile() : _fileList(0), _isAmiga(false) {}
+ ~PAKFile() { delete _fileList; }
+
+ bool loadFile(const char *file, const bool isAmiga);
+ bool saveFile(const char *file);
+ void clearFile() { delete _fileList; _fileList = 0; }
+
+ uint32 getFileSize() const { return _fileList->getTableSize()+5+4+_fileList->getFileSize(); }
+
+ void drawFileList();
+
+ bool outputAllFiles();
+
+ bool outputFile(const char *file) { return outputFileAs(file, file); }
+ bool outputFileAs(const char *file, const char *outputName);
+ const uint8 *getFileData(const char *file, uint32 *size);
+
+ bool addFile(const char *name, const char *file);
+ bool addFile(const char *name, uint8 *data, uint32 size);
+
+ bool removeFile(const char *name);
+public:
+ struct FileList {
+ FileList() : filename(0), size(0), data(0), next(0) {}
+ ~FileList() {
+ delete[] filename;
+ delete[] data;
+ delete next;
+ }
+
+ FileList *findEntry(const char *f) {
+ for (FileList *cur = this; cur; cur = cur->next) {
+ if (scumm_stricmp(cur->filename, f) != 0)
+ continue;
+ return cur;
+ }
+ return 0;
+ }
+
+ const FileList *findEntry(const char *f) const {
+ for (const FileList *cur = this; cur; cur = cur->next) {
+ if (scumm_stricmp(cur->filename, f) != 0)
+ continue;
+ return cur;
+ }
+ return 0;
+ }
+
+ void addEntry(FileList *e) {
+ if (next)
+ next->addEntry(e);
+ else
+ next = e;
+ }
+ uint32 getTableSize() const {
+ return strlen(filename)+1+4+((next != 0) ? next->getTableSize() : 0);
+ }
+ uint32 getFileSize() const {
+ return size + (next != 0 ? next->getFileSize() : 0);
+ }
+
+ char *filename;
+ uint32 size;
+ uint8 *data;
+
+ FileList *next;
+ };
+
+ typedef const FileList cFileList;
+
+ cFileList *getFileList() const { return _fileList; }
+private:
+ FileList *_fileList;
+ bool _isAmiga;
+};
+
+#endif