[Scummvm-cvs-logs] SF.net SVN: scummvm:[55592] tools/trunk/engines/mohawk/extract_mohawk.cpp

tdhs at users.sourceforge.net tdhs at users.sourceforge.net
Fri Jan 28 15:55:56 CET 2011


Revision: 55592
          http://scummvm.svn.sourceforge.net/scummvm/?rev=55592&view=rev
Author:   tdhs
Date:     2011-01-28 14:55:56 +0000 (Fri, 28 Jan 2011)

Log Message:
-----------
TOOLS: Fix extract_mohawk tool to allow extraction of resources with '/' or '\' in names.

The extraction of the resources with forward slashes in names was not possible as these are invalid in paths as they are directory seperators on Unix.

This commit fixes this by replacing them with backslashes, which can be present in filenames.

However in order to allow this operation to be unambiguously reversed by construct_mohawk, it is also necessary to pad any backslashes present prior to this to allow them to be disambiguated.

Modified Paths:
--------------
    tools/trunk/engines/mohawk/extract_mohawk.cpp

Modified: tools/trunk/engines/mohawk/extract_mohawk.cpp
===================================================================
--- tools/trunk/engines/mohawk/extract_mohawk.cpp	2011-01-28 14:19:39 UTC (rev 55591)
+++ tools/trunk/engines/mohawk/extract_mohawk.cpp	2011-01-28 14:55:56 UTC (rev 55592)
@@ -132,8 +132,21 @@
 	if (fileTableFlags)
 		sprintf(strBuf + strlen(strBuf), "%02x_", output.flags);
 	sprintf(strBuf + strlen(strBuf), "%s_%d", tag2str(output.tag), output.id);
-	if (!output.name.empty())
+	if (!output.name.empty()) {
+		for (uint i = 0; i < output.name.size(); i++) {
+			//printf("DEBUG: i: %d output.name[i]: %c\n", i, output.name[i]);
+			if (output.name[i] == '\\') {
+				//printf("\tPadded \ at %d with %c\n", i, '\\');
+				output.name.insertChar('\\', i);
+				i++;
+			}
+			if (output.name[i] == '/') {
+				//printf("\tReplaced / at %d with %c\n", i, '\\');
+				output.name.setChar('\\', i);
+			}
+		}
 		sprintf(strBuf + strlen(strBuf), "_%s", output.name.c_str());
+	}
 	output.name = strBuf;
 
 	if (doConversion) {


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