[Scummvm-cvs-logs] SF.net SVN: scummvm: [25256] tools/trunk

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Mon Jan 29 19:12:48 CET 2007


Revision: 25256
          http://scummvm.svn.sourceforge.net/scummvm/?rev=25256&view=rev
Author:   lordhoto
Date:     2007-01-29 10:12:47 -0800 (Mon, 29 Jan 2007)

Log Message:
-----------
little cleanup.

Modified Paths:
--------------
    tools/trunk/kyra_pak.cpp
    tools/trunk/kyra_pak.h

Modified: tools/trunk/kyra_pak.cpp
===================================================================
--- tools/trunk/kyra_pak.cpp	2007-01-29 17:59:28 UTC (rev 25255)
+++ tools/trunk/kyra_pak.cpp	2007-01-29 18:12:47 UTC (rev 25256)
@@ -68,23 +68,12 @@
 		}
 		position += 4;
 		
-		FileList *newEntry = new FileList;
-		assert(newEntry);
+		uint8 *data = new uint8[endoffset - startoffset];
+		assert(data);
+		memcpy(data, buffer + startoffset, endoffset - startoffset);
+		addFile(currentName, data, endoffset - startoffset);
+		data = 0;
 		
-		newEntry->filename = new char[strlgt+1];
-		assert(newEntry->filename);
-		memcpy(newEntry->filename, currentName, strlgt+1);
-		newEntry->size = endoffset - startoffset;
-		newEntry->data = new uint8[newEntry->size];
-		assert(newEntry->data);
-		memcpy(newEntry->data, buffer + startoffset, newEntry->size);
-		
-		if (_fileList) {
-			_fileList->addEntry(newEntry);
-		} else {
-			_fileList = newEntry;
-		}
-		
 		if (endoffset == filesize)
 			break;
 		
@@ -173,7 +162,7 @@
 		error("couldn't open file '%s' in write mode", fn);
 		return false;
 	}
-	printf("Exracting file '%s'...", cur->filename);
+	printf("Exracting file '%s' to file '%s'...", cur->filename, fn);
 	if (fwrite(cur->data, 1, cur->size, file) == cur->size) {
 		printf("OK\n");
 	} else {
@@ -230,7 +219,7 @@
 	assert(newEntry);
 	newEntry->filename = new char[strlen(name)+1];
 	assert(newEntry->filename);
-	strcpy(newEntry->filename, name);
+	strncpy(newEntry->filename, name, strlen(name)+1);
 	newEntry->size = size;
 	newEntry->data = data;
 
@@ -239,6 +228,21 @@
 	} else {
 		_fileList = newEntry;
 	}
-
 	return true;
 }
+
+bool PAKFile::removeFile(const char *name) {
+	for (FileList *cur = _fileList, *last = 0; cur; last = cur, cur = cur->next) {
+		if (scumm_stricmp(cur->filename, name) == 0) {
+			FileList *next = cur->next;
+			cur->next = 0;
+			delete cur;
+			if (last)
+				last->next = next;
+			else
+				_fileList = next;
+			return true;
+		}
+	}
+	return false;
+}

Modified: tools/trunk/kyra_pak.h
===================================================================
--- tools/trunk/kyra_pak.h	2007-01-29 17:59:28 UTC (rev 25255)
+++ tools/trunk/kyra_pak.h	2007-01-29 18:12:47 UTC (rev 25256)
@@ -44,6 +44,8 @@
 
 	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) {}


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list