[Scummvm-cvs-logs] CVS: scummvm/scumm wiz_he.cpp,2.68,2.69

Eugene Sandulenko sev at users.sourceforge.net
Sat Apr 30 13:49:39 CEST 2005


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18268

Modified Files:
	wiz_he.cpp 
Log Message:
Convert windows path separators before opening wiz files.


Index: wiz_he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/wiz_he.cpp,v
retrieving revision 2.68
retrieving revision 2.69
diff -u -d -r2.68 -r2.69
--- wiz_he.cpp	30 Apr 2005 05:25:06 -0000	2.68
+++ wiz_he.cpp	30 Apr 2005 20:48:59 -0000	2.69
@@ -1631,6 +1631,9 @@
 }
 
 void ScummEngine_v90he::processWizImage(const WizParameters *params) {
+	char buf[512];
+	unsigned int i;
+
 	debug(2, "processWizImage: processMode %d", params->processMode);
 	switch (params->processMode) {
 	case 0:
@@ -1645,7 +1648,15 @@
 	case 3:
 		if (params->processFlags & kWPFUseFile) {
 			File f;
-			if (f.open((const char *)params->filename, File::kFileReadMode)) {
+
+			// Convert Windows path separators to something more portable
+			strncpy(buf, (const char *)params->filename, 512);
+			for (i = 0; i < strlen(buf); i++) {
+				if (buf[i] == '\\')
+					buf[i] = '/';
+			}
+
+			if (f.open((const char *)buf, File::kFileReadMode)) {
 				uint32 id = f.readUint32LE();
 				if (id == TO_LE_32(MKID('AWIZ')) || id == TO_LE_32(MKID('MULT'))) {
 					uint32 size = f.readUint32BE();
@@ -1653,7 +1664,7 @@
 					byte *p = res.createResource(rtImage, params->img.resNum, size);
 					if (f.read(p, size) != size) {
 						res.nukeResource(rtImage, params->img.resNum);
-						warning("i/o error when reading '%s'", params->filename);
+						warning("i/o error when reading '%s'", buf);
 						VAR(VAR_GAME_LOADED) = -2;
 						VAR(119) = -2;
 					} else {
@@ -1668,7 +1679,7 @@
 			} else {
 				VAR(VAR_GAME_LOADED) = -3;
 				VAR(119) = -3;
-				warning("Unable to open for read '%s'", params->filename);
+				warning("Unable to open for read '%s'", buf);
 			}
 		}
 		break;
@@ -1684,8 +1695,15 @@
 				// TODO Write image to file
 				break;
 			case 0:
-				if (!f.open((const char *)params->filename, File::kFileWriteMode)) {
-					warning("Unable to open for write '%s'", params->filename);
+				// Convert Windows path separators to something more portable
+				strncpy(buf, (const char *)params->filename, 512);
+				for (i = 0; i < strlen(buf); i++) {
+					if (buf[i] == '\\')
+						buf[i] = '/';
+				}
+
+				if (!f.open((const char *)buf, File::kFileWriteMode)) {
+					warning("Unable to open for write '%s'", buf);
 					VAR(119) = -3;
 				} else {
 					byte *p = getResourceAddress(rtImage, params->img.resNum);





More information about the Scummvm-git-logs mailing list