[Scummvm-cvs-logs] SF.net SVN: scummvm: [28171] tools/branches/gsoc2007-toolsgui/extract_kyra. cpp

lightcast at users.sourceforge.net lightcast at users.sourceforge.net
Mon Jul 23 02:30:19 CEST 2007


Revision: 28171
          http://scummvm.svn.sourceforge.net/scummvm/?rev=28171&view=rev
Author:   lightcast
Date:     2007-07-22 17:30:18 -0700 (Sun, 22 Jul 2007)

Log Message:
-----------
Modified extract_kyra so that optional arguments come before the filename, so that it functions like all the other tools.

Modified Paths:
--------------
    tools/branches/gsoc2007-toolsgui/extract_kyra.cpp

Modified: tools/branches/gsoc2007-toolsgui/extract_kyra.cpp
===================================================================
--- tools/branches/gsoc2007-toolsgui/extract_kyra.cpp	2007-07-23 00:16:37 UTC (rev 28170)
+++ tools/branches/gsoc2007-toolsgui/extract_kyra.cpp	2007-07-23 00:30:18 UTC (rev 28171)
@@ -25,7 +25,7 @@
 
 void showhelp(char* exename)
 {
-		printf("\nUsage: %s <file> [params]\n", exename);
+		printf("\nUsage: %s [params] <file>\n", exename);
 
 		printf("\nParams:\n");
 		printf("-o <filename>     Extract only <filename>\n");
@@ -41,6 +41,7 @@
 	}
 
 	bool extractAll = false, extractOne = false, isAmiga = false;
+	char singleFilename[256] = "";
 	int param;
 
 	for (param = 1; param < argc; param++) {
@@ -48,30 +49,34 @@
 			extractOne = true;
 			param++;
 
-			if (param >= argc) {
-				printf("You supply a filename with -o\n");
-				printf("Example: %s A_E.PAK -o ALGAE.CPS\n", argv[0]);
+			if (param >= (argc - 1)) {
+				printf("You must supply a filename with -o\n");
+				printf("Example: %s -o ALGAE.CPS A_E.PAK\n", argv[0]);
 
 				exit(-1);
+			} else {
+				strcpy(singleFilename, argv[param]);
 			}
 		} else if (strcmp(argv[param], "-x") == 0) {
 			extractAll = true;
 		} else if (strcmp(argv[param], "-a") == 0) {
 			isAmiga = true;
-		} else {
-			showhelp(argv[0]);
 		}
 	}
 
+	if (param > argc) {
+		showhelp(argv[0]);
+	}
+
 	PAKFile myfile;
-	if (!myfile.loadFile(argv[1], isAmiga)) {
-		error("Couldn't load file '%s'", argv[1]);
+	if (!myfile.loadFile(argv[argc - 1], isAmiga)) {
+		error("Couldn't load file '%s'", argv[argc - 1]);
 	}
 
 	if(extractAll) {
 		myfile.outputAllFiles();
 	} else if(extractOne) {
-		myfile.outputFile(argv[param]);
+		myfile.outputFile(singleFilename);
 	} else {
 		myfile.drawFileList();
 	}


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