Subversion Repositories spk

Rev

Rev 131 | Rev 152 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 131 Rev 134
Line 21... Line 21...
21
#include <shlobj.h>
21
#include <shlobj.h>
22
#endif
22
#endif
23
 
23
 
24
CyString g_dir;
24
CyString g_dir;
25
bool g_read;
25
bool g_read;
-
 
26
 
-
 
27
class CFileProgress : public CProgressInfo
-
 
28
{
-
 
29
private:
-
 
30
	Utils::String _display;
-
 
31
	CBaseFile *_package;
-
 
32
	CPackages *_packages;
-
 
33
 
-
 
34
public:
-
 
35
	CFileProgress(CPackages *packages, CBaseFile *package, const Utils::String &display) : 
-
 
36
		_display(display),
-
 
37
		_packages(packages),
-
 
38
		_package(package)
-
 
39
	{
-
 
40
 
-
 
41
	}
-
 
42
 
-
 
43
protected:
-
 
44
	void ProgressUpdated(const long cur, const long max)
-
 
45
	{
-
 
46
	}
-
 
47
	void DoingFile(C_File *file)
-
 
48
	{
-
 
49
		Utils::String game;
-
 
50
 
-
 
51
		if (!file->game() || file->game() == GAME_ALLNEW)
-
 
52
			game = "All Games";
-
 
53
		else if (_packages)
-
 
54
		{
-
 
55
			for (unsigned int i = 0; i < 31; ++i)
-
 
56
			{
-
 
57
				if (file->game() & (1 << i))
-
 
58
				{
-
 
59
					Utils::String g = _packages->GetGameExe()->GetGameNameFromType(i - 1);
-
 
60
					if (!g.empty())
-
 
61
					{
-
 
62
						if (game.empty())
-
 
63
							game = g;
-
 
64
						else
-
 
65
							game = game + ", " + g;
-
 
66
					}
-
 
67
				}
-
 
68
			}
-
 
69
		}
-
 
70
 
-
 
71
		if(game.empty())
-
 
72
			printf("%s: %s\n", _display.c_str(), file->getNameDirectory(_package).c_str());
-
 
73
		else
-
 
74
			printf("%s: %s [%s]\n", _display.c_str(), file->getNameDirectory(_package).c_str(), game.c_str());
-
 
75
	}
-
 
76
 
-
 
77
};
26
 
78
 
27
/*
79
/*
28
	Func:	GetInput
80
	Func:	GetInput
29
	Desc:	Gets an input from the user, ie, any settings required to be typed in
81
	Desc:	Gets an input from the user, ie, any settings required to be typed in
30
*/
82
*/
Line 52... Line 104...
52
*/
104
*/
53
void PrintSyntax ( CyString cmd )
105
void PrintSyntax ( CyString cmd )
54
{
106
{
55
	printf ( "Syntax: %s <command>\n", cmd.c_str() );
107
	printf ( "Syntax: %s <command>\n", cmd.c_str() );
56
	printf ( "Commands:\n" );
108
	printf ( "Commands:\n" );
57
	printf ( "\t-v <spkfile>\n\t--version <spkfile>\n\t\tViews the contents of a spk file\n\n" );
109
	printf ( "\t-v <spkfile>\n\t--view <spkfile>\n\t\tViews the contents of a spk file\n\n" );
58
	printf ( "\t-e <spkfile> [destination]\n\t--extractall <spkfile> [destination]\n\t\tExtracts all the files to the destination directory [or current if no destiantion is set]\n\n" );
110
	printf ( "\t-e <spkfile> [destination]\n\t--extractall <spkfile> [destination]\n\t\tExtracts all the files to the destination directory [or current if no destiantion is set]\n\n" );
59
	printf ( "\t-x <spkfile> <type> <file> [destination]\n\t--extract <spkfile> <type> <file> [destination]\n\t\tExtracts a single file of <type> to destination directory\n\n" );
111
	printf ( "\t-x <spkfile> <type> <file> [destination]\n\t--extract <spkfile> <type> <file> [destination]\n\t\tExtracts a single file of <type> to destination directory\n\n" );
60
	printf ( "\t-x <multispkfile> <file> [destination]\n\t--extractspk <multispkfile> <spkfile> [destination]\n\t\tExtracts a single spk file from a Multi-Spk Package\n\n" );
112
	printf ( "\t-x <multispkfile> <file> [destination]\n\t--extractspk <multispkfile> <spkfile> [destination]\n\t\tExtracts a single spk file from a Multi-Spk Package\n\n" );
61
	printf ( "\t-c <spkfile>\n\t--create\n\t\tCreates a new spk file\n\n" );
113
	printf ( "\t-c <spkfile>\n\t--create\n\t\tCreates a new spk file\n\n" );
62
	printf ( "\t-a <spkfile> <type> <filename>\n\t--append <spkfile> <type> <filename>\n\t\tAppends a file to the package of set <type>\n\n" );
114
	printf ( "\t-a <spkfile> <type> <filename>\n\t--append <spkfile> <type> <filename>\n\t\tAppends a file to the package of set <type>\n\n" );
Line 355... Line 407...
355
		case GAME_X3FL:
407
		case GAME_X3FL:
356
			return "X3: Farnham's Legacy";
408
			return "X3: Farnham's Legacy";
357
	}
409
	}
358
	return "Unknown";
410
	return "Unknown";
359
}
411
}
360
void DisplayVersion ( CyString filename )
412
void DisplayVersion(const Utils::String &filename)
361
{
413
{
362
	// first chekc if file even exists
414
	// first chekc if file even exists
363
	FILE *id = fopen ( filename.c_str(), "rb+" );
415
	FILE *id = fopen ( filename.c_str(), "rb+" );
364
	if ( !id )
416
	if ( !id )
365
	{
417
	{
Line 408... Line 460...
408
	// otherwise its an old ship file
460
	// otherwise its an old ship file
409
	else if ( CFileIO(filename).CheckFileExtension("xsp") )
461
	else if ( CFileIO(filename).CheckFileExtension("xsp") )
410
	{
462
	{
411
		printf ( "* Converting XSP File, %s...\n", filename.c_str() );
463
		printf ( "* Converting XSP File, %s...\n", filename.c_str() );
412
		pBaseFile = new CXspFile;
464
		pBaseFile = new CXspFile;
413
		if ( !((CXspFile *)pBaseFile)->ConvertOld(filename.ToString()) )
465
		if ( !((CXspFile *)pBaseFile)->ConvertOld(filename) )
414
		{
466
		{
415
			delete pBaseFile;
467
			delete pBaseFile;
416
			pBaseFile = NULL;
468
			pBaseFile = NULL;
417
			printf ( "Failed to convert old xsp file, %s\n", filename.c_str() );
469
			printf ( "Failed to convert old xsp file, %s\n", filename.c_str() );
418
			return;
470
			return;
Line 422... Line 474...
422
	}
474
	}
423
 
475
 
424
	if ( pBaseFile && read)
476
	if ( pBaseFile && read)
425
	{
477
	{
426
		CPackages p;
478
		CPackages p;
427
		p.Startup(".", ".", ".");
479
		p.startup(".", ".", ".");
428
 
480
 
429
		CSpkFile *pSpkFile = NULL;
481
		CSpkFile *pSpkFile = NULL;
430
		CXspFile *pXspFile = NULL;
482
		CXspFile *pXspFile = NULL;
431
		if ( check == SPKFILE_SINGLE )
483
		if ( check == SPKFILE_SINGLE )
432
			pSpkFile = (CSpkFile *)pBaseFile;
484
			pSpkFile = (CSpkFile *)pBaseFile;
Line 573... Line 625...
573
		if ( pBaseFile->gameChanging() != -1 ) printf ( "Game Changing Rating: %d\n", pBaseFile->gameChanging() );
625
		if ( pBaseFile->gameChanging() != -1 ) printf ( "Game Changing Rating: %d\n", pBaseFile->gameChanging() );
574
		if ( pBaseFile->recommended() != -1 ) printf ( "Recommendation Rating: %d\n", pBaseFile->recommended() );
626
		if ( pBaseFile->recommended() != -1 ) printf ( "Recommendation Rating: %d\n", pBaseFile->recommended() );
575
		if ( pBaseFile->GetIcon() )
627
		if ( pBaseFile->GetIcon() )
576
		{
628
		{
577
			C_File *icon = pBaseFile->GetIcon();
629
			C_File *icon = pBaseFile->GetIcon();
578
			printf ( "Icon File Found, Type: %s, Size: %s\n", pBaseFile->GetIconExt().c_str(), icon->GetDataSizeString().c_str() );
630
			printf ( "Icon File Found, Type: %s, Size: %s\n", pBaseFile->GetIconExt().c_str(), icon->dataSizeString().c_str() );
579
		}
631
		}
580
 
632
 
581
		if ( pBaseFile->GetFileList()->size() )
633
		if ( pBaseFile->GetFileList()->size() )
582
		{
634
		{
583
			printf ( "\nListing files in package:\n" );
635
			printf("\nListing files in package:\n");
584
			if ( pBaseFile->GetIcon() )
-
 
585
				printf("\tIcon: %s (Size: %s)\n", pBaseFile->GetIconExt().c_str(), pBaseFile->GetIcon()->GetDataSizeString().c_str());
-
 
586
			CLinkList<C_File> *list = pBaseFile->GetFileList();
636
			CLinkList<C_File> *list = pBaseFile->GetFileList();
-
 
637
 
-
 
638
			for (unsigned int game = 0; game < 31; ++game)
-
 
639
			{
-
 
640
				bool heading = true;
587
			for ( C_File *file = list->;First(); file; file = list->Next() )
641
				for (C_File *file = list->First(); file; file = list->Next())
-
 
642
				{
-
 
643
					bool display = false;
-
 
644
					if (game == 0 && (!file->game() || file->game() == GAME_ALLNEW))
-
 
645
						display = true;
-
 
646
					if (game > 0 && file->game() & (1 << game))
-
 
647
						display = true;
-
 
648
 
-
 
649
					if (display)
-
 
650
					{
-
 
651
						if (heading)
-
 
652
						{
-
 
653
							Utils::String sGame = p.GetGameExe()->GetGameNameFromType(game - 1);
-
 
654
							printf("\tGame: %s\n", sGame.c_str());
-
 
655
							heading = false;
-
 
656
						}
588
				printf ( "\t%s (%s) Size: %s\n";, file->;GetNameDirectory(pBaseFile).c_str(), file->GetFileTypeString().c_str(), file->GetDataSizeString().c_str() );
657
						printf("\t\t%s (%s) Size: %s\n";, file->;GetNameDirectory(pBaseFile).c_str(), file->fileTypeString().c_str(), file->dataSizeString().c_str());
-
 
658
 
-
 
659
					}
-
 
660
				}
-
 
661
			}
-
 
662
 
589
		}
663
		}
590
		else
664
		else
591
			printf ( "\nThere are currently no files in the package\n" );
665
			printf ( "\nThere are currently no files in the package\n" );
592
	}
666
	}
593
	else if ( check == SPKFILE_MULTI )
667
	else if ( check == SPKFILE_MULTI )
Line 796... Line 870...
796
		CyString i = GetInput();
870
		CyString i = GetInput();
797
		i = i.ToUpper();
871
		i = i.ToUpper();
798
		if ( i == "Y" )
872
		if ( i == "Y" )
799
			spkfile.SetSelection ( true );
873
			spkfile.SetSelection ( true );
800
		if ( (i == "Y") || (i == "N") )
874
		if ( (i == "Y") || (i == "N") )
801
			break;
875
			break;
802
	}
876
	}
803
 
877
 
804
	while ( true )
878
	while ( true )
805
	{
879
	{
806
		printf ( "\nEnter Spk File to add (Enter \"0\" to finish): " );
880
		printf ( "\nEnter Spk File to add (Enter \"0\" to finish): " );
807
		sInput = GetInput();
881
		sInput = GetInput();
Line 827... Line 901...
827
	else
901
	else
828
	{
902
	{
829
		printf ( "Writing MultiSpk file... " );
903
		printf ( "Writing MultiSpk file... " );
830
		if ( spkfile.WriteFile ( filename ) )
904
		if ( spkfile.WriteFile ( filename ) )
831
			printf ( "(Done)\n" );
905
			printf ( "(Done)\n" );
832
		else
906
		else
833
			printf ( "(Error)\n" );
907
			printf ( "(Error)\n" );
834
	}
908
	}
835
 
909
 
836
}
910
}
837
 
911
 
Line 842... Line 916...
842
	FILE *id = fopen ( filename.c_str(), "rb+" );
916
	FILE *id = fopen ( filename.c_str(), "rb+" );
843
	if ( id )
917
	if ( id )
844
	{
918
	{
845
		fclose ( id );
919
		fclose ( id );
846
		printf ( "* File already exists, unable to create\n" );
920
		printf ( "* File already exists, unable to create\n" );
847
		return;
921
		return;
848
	}
922
	}
849
 
923
 
850
	id = fopen ( filename.c_str(), "wb" );
924
	id = fopen ( filename.c_str(), "wb" );
851
	if ( !id )
925
	if ( !id )
852
	{
926
	{
Line 918... Line 992...
918
			printf ( "(Error)\nUnable to open the file, %s\n", sfile.c_str() );
992
			printf ( "(Error)\nUnable to open the file, %s\n", sfile.c_str() );
919
			return;
993
			return;
920
		}
994
		}
921
		printf ( "(Done)\n" );
995
		printf ( "(Done)\n" );
922
 
996
 
-
 
997
		if(game == 0)
923
		printf ( ";Extracting all files from archive..." );
998
			printf(";Extracting all files from archive...\n\n");
-
 
999
		else
-
 
1000
			printf("Extracting %s files from archive...\n\n", packages.GetGameExe()->GetGameNameFromType(game - 1).c_str());
-
 
1001
 
-
 
1002
		CFileProgress info(&packages, pBaseFile, "Extracting");
924
		if (packages.extractAll(pBaseFile, dir, game) )
1003
		if (packages.extractAll(pBaseFile, dir, game, true, &info) )
925
			printf ( "(Done)\nFiles have been extracted successfully\n" );
1004
			printf ( "\n(Done)\nFiles have been extracted successfully\n" );
926
		else
1005
		else
927
			printf ( "(Error)\nThere was a problem extracting the files\n" );
1006
			printf ( "\n(Error)\nThere was a problem extracting the files\n" );
928
	}
1007
	}
929
	else
1008
	else
930
		printf("Invalid package file, %s\n", sfile.c_str());
1009
		printf("Invalid package file, %s\n", sfile.c_str());
931
}
1010
}
932
 
1011
 
Line 992... Line 1071...
992
			String type		- the type of the file to find
1071
			String type		- the type of the file to find
993
			String addfile	- The filename to extract
1072
			String addfile	- The filename to extract
994
			String dir		- The directory to extract to
1073
			String dir		- The directory to extract to
995
	Desc:	Finds and extracts a file from a Spk Package
1074
	Desc:	Finds and extracts a file from a Spk Package
996
*/
1075
*/
997
void ExtractFile ( CyString sfile, CyString type, CyString addfile, CyString dir )
1076
void ExtractFile (const Utils::String &sfile, const Utils::String &type, const Utils::String &addfile, const Utils::String &dir)
998
{
1077
{
999
	// First checks if the file exists by opening it
1078
	// First checks if the file exists by opening it
1000
	FILE *id = fopen ( sfile.c_str(), "rb+" );
1079
	FILE *id = fopen ( sfile.c_str(), "rb+" );
1001
	if ( !id )
1080
	if ( !id )
1002
	{
1081
	{
Line 1185... Line 1264...
1185
			Utils::String file = (*itr)->str;
1264
			Utils::String file = (*itr)->str;
1186
			Utils::String data = (*itr)->data;
1265
			Utils::String data = (*itr)->data;
1187
			if (data == "file")
1266
			if (data == "file")
1188
				fileList.pushBack(file);
1267
				fileList.pushBack(file);
1189
			else if (data == "dir")
1268
			else if (data == "dir")
1190
			{
1269
			{
1191
				CDirIO dir(file);
1270
				CDirIO dir(file);
1192
				Utils::CStringList d;
1271
				Utils::CStringList d;
1193
				if (dir.dirList(d))
1272
				if (dir.dirList(d))
1194
				{
1273
				{
1195
					for (auto itr2 = d.begin(); itr2 != d.end(); itr2++)
1274
					for (auto itr2 = d.begin(); itr2 != d.end(); itr2++)
Line 1275... Line 1354...
1275
	if ( check == SPKFILE_MULTI )
1354
	if ( check == SPKFILE_MULTI )
1276
	{
1355
	{
1277
		printf("Error: Multi-Package files currently not supported\n");
1356
		printf("Error: Multi-Package files currently not supported\n");
1278
		return;
1357
		return;
1279
	}
1358
	}
1280
	else if ( check == SPKFILE_OLD )
1359
	else if ( check == SPKFILE_OLD )
1281
	{
1360
	{
1282
		printf("Error: unable to read old format spk file, try spkconvert first\n");
1361
		printf("Error: unable to read old format spk file, try spkconvert first\n");
1283
		return;
1362
		return;
1284
	}
1363
	}
1285
	else if ( check == SPKFILE_INVALID )
1364
	else if ( check == SPKFILE_INVALID )
1286
	{
1365
	{
1287
		printf("Error: %s doesn't appear to be a valid package file\n", spkfile.c_str());
1366
		printf("Error: %s doesn't appear to be a valid package file\n", spkfile.c_str());
1288
		return;
1367
		return;
1289
	}
1368
	}
1290
 
1369
 
1291
	CPackages p;
1370
	CPackages p;
1292
	int error;
1371
	int error;
1293
	CBaseFile *package = p.OpenPackage(spkfile, &error, 0, SPKREAD_NODATA);
1372
	CBaseFile *package = p.OpenPackage(spkfile, &error, 0, SPKREAD_NODATA);
1294
	if ( !package )
1373
	if ( !package )
1295
	{
1374
	{
1296
		printf("Error: unable to open package file, %s, Error=%d\n", spkfile.c_str(), error);
1375
		printf("Error: unable to open package file, %s, Error=%d\n", spkfile.c_str(), error);
1297
		return;
1376
		return;
1298
	}
1377
	}
1299
 
1378
 
1300
	Utils::String file = package->CreateUpdateFile(CFileIO(spkfile).dir()).ToString();
1379
	Utils::String file = package->createUpdateFile(CFileIO(spkfile).dir());
1301
	if ( file.empty() )
1380
	if ( file.empty() )
1302
		printf("Error: unable to create update file for: %s, Directory=%s\n", spkfile.c_str(), CFileIO(spkfile).dir().c_str());
1381
		printf("Error: unable to create update file for: %s, Directory=%s\n", spkfile.c_str(), CFileIO(spkfile).dir().c_str());
1303
	else
1382
	else
1304
		printf("Update file: %s has been created for package, %s\n", file.c_str(), spkfile.c_str());
1383
		printf("Update file: %s has been created for package, %s\n", file.c_str(), spkfile.c_str());
1305
 
1384
 
1306
	delete package;
1385
	delete package;
1307
 
1386
 
1308
}
1387
}
1309
 
1388
 
1310
void GeneratePackagerScript(const Utils::String &spkfile, CyString toFile, int game)
1389
void GeneratePackagerScript(const Utils::String &spkfile, CyString toFile, int game)
1311
{
1390
{
1312
	if (!CFileIO::Exists(spkfile))
1391
	if (!CFileIO::Exists(spkfile))
1313
	{
1392
	{
1314
		printf("Error: The package file, %s, does not exist", spkfile.c_str());
1393
		printf("Error: The package file, %s, does not exist", spkfile.c_str());
1315
		return;
1394
		return;
1316
	}
1395
	}
Line 1378... Line 1457...
1378
#ifdef _WIN32
1457
#ifdef _WIN32
1379
	TCHAR pszPath[MAX_PATH];
1458
	TCHAR pszPath[MAX_PATH];
1380
	if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, pszPath)))
1459
	if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, pszPath)))
1381
	{
1460
	{
1382
		myDoc = (char *)pszPath;
1461
		myDoc = (char *)pszPath;
1383
	}
1462
	}
1384
#endif
1463
#endif
1385
 
1464
 
1386
	if ( verify )
1465
	if ( verify )
1387
		printf("Verifying Packager Script: %s\n", filename.c_str());
1466
		printf("Verifying Packager Script: %s\n", filename.c_str());
1388
 
1467
 
1389
	CPackages p;
1468
	CPackages p;
1390
	p.startup(".", ".", myDoc);
1469
	p.startup(".", ".", myDoc);
1391
	Utils::CStringList malformed, unknown;
1470
	Utils::CStringList malformed, unknown;
1392
 
1471
 
1393
	Utils::String curDir = CFileIO(filename).dir();
1472
	Utils::String curDir = CFileIO(filename).dir();
1394
	if ( curDir.empty() ) curDir = "./";
1473
	if ( curDir.empty() ) curDir = "./";
1395
 
1474
 
1396
	Utils::CStringList variables;
1475
	Utils::CStringList variables;
1397
	variables.pushBack("$PATH", curDir);
1476
	variables.pushBack("$PATH", curDir);
1398
 
1477
 
-
 
1478
	CFileProgress info(&p, NULL, "Adding File");
1399
	CBaseFile *package = p.LoadPackagerScript(filename, -1, (verify) ? NULL : &GetAsk, &malformed, &unknown, &variables);
1479
	CBaseFile *package = p.LoadPackagerScript(filename, -1, (verify) ? NULL : &GetAsk, &malformed, &unknown, &variables, &info);
-
 
1480
 
-
 
1481
	printf("\n");
1400
 
1482
 
1401
	if ( verify )
1483
	if ( verify )
1402
	{
1484
	{
1403
		if ( !malformed.empty() )
1485
		if ( !malformed.empty() )
1404
		{
1486
		{
1405
			printf("Malformed Lines (%d):\n", malformed.size());
1487
			printf("Malformed Lines (%d):\n", malformed.size());
1406
			for(auto itr = malformed.begin(); itr != malformed.end(); itr++)				
1488
			for(auto itr = malformed.begin(); itr != malformed.end(); itr++)				
1407
				printf("\t(Line %3d) %s\n", (*itr)->data.toInt(), (*itr)->str.c_str());
1489
				printf("\t(Line %3d) %s\n", (*itr)->data.toInt(), (*itr)->str.c_str());
1408
		}
1490
		}
1409
		if ( !unknown.empty() )
1491
		if ( !unknown.empty() )
1410
		{
1492
		{
1411
			printf("Unknown Commands (%d):\n", unknown.size());
1493
			printf("Unknown Commands (%d):\n", unknown.size());
1412
			for (auto itr = unknown.begin(); itr != unknown.end(); itr++)
1494
			for (auto itr = unknown.begin(); itr != unknown.end(); itr++)
1413
				printf("\t* Command: %s = %s\n", (*itr)->str.c_str(), (*itr)->data.c_str());
1495
				printf("\t* Command: %s = %s\n", (*itr)->str.c_str(), (*itr)->data.c_str());
Line 1439... Line 1521...
1439
		{
1521
		{
1440
			// write script
1522
			// write script
1441
			if ( package->WriteFile(saveto) )
1523
			if ( package->WriteFile(saveto) )
1442
			{
1524
			{
1443
				if ( package->AutoGenerateUpdateFile() )
1525
				if ( package->AutoGenerateUpdateFile() )
1444
					package->CreateUpdateFile(CFileIO(saveto).dir());
1526
					package->createUpdateFile(CFileIO(saveto).dir());
1445
				printf("Package: %s was created\n", saveto.c_str());
1527
				printf("Package: %s was created\n", saveto.c_str());
1446
			}
1528
			}
1447
			else
1529
			else
1448
				printf("Error! There was a problem writing the package\n");
1530
				printf("Error! There was a problem writing the package\n");
1449
		}
1531
		}
Line 1516... Line 1598...
1516
			}
1598
			}
1517
		}
1599
		}
1518
	}
1600
	}
1519
 
1601
 
1520
	// get the command flag
1602
	// get the command flag
1521
	CyString command(argv[1]);
1603
	Utils::String command(argv[1]);
1522
 
1604
 
1523
	// display the contents of the spk file
1605
	// display the contents of the spk file
1524
	if ( command == "-v" || command == "--version" )
1606
	if ( command == "-v" || command == "--view" || command == "--version")
1525
	{
1607
	{
1526
		if ( argc < 3 )
1608
		if ( argc < 3 )
1527
			printf ( "Syntax: %s -v <spkfile>\n\tWill open and display the contents of the spkfile\n", cmd.c_str() );
1609
			printf ( "Syntax: %s -v <spkfile>\n\tWill open and display the contents of the spkfile\n", cmd.c_str() );
1528
		else
1610
		else
1529
			DisplayVersion ( argv[2] );
1611
			DisplayVersion(argv[2]);
1530
	}
1612
	}
1531
 
1613
 
1532
	// creates a new spk file
1614
	// creates a new spk file
1533
	else if ( command == "-c" || command == "--create" )
1615
	else if ( command == "-c" || command == "--create" )
1534
	{
1616
	{
Line 1574... Line 1656...
1574
	{
1656
	{
1575
		if ( argc < 4 )
1657
		if ( argc < 4 )
1576
			printf ( "Syntax:\n\t%s --extractspk <multispkfile> <filename> [destination]\n\tThis will extract a spk file from the Multi-Spk package and save it to the destination path\n", cmd.c_str() );
1658
			printf ( "Syntax:\n\t%s --extractspk <multispkfile> <filename> [destination]\n\tThis will extract a spk file from the Multi-Spk package and save it to the destination path\n", cmd.c_str() );
1577
		else
1659
		else
1578
		{
1660
		{
1579
			CyString arg4;
1661
			Utils::String arg4;
1580
			if ( argc > 4 )
1662
			if ( argc > 4 )
1581
				arg4 = argv[3];
1663
				arg4 = argv[3];
1582
			ExtractFile ( argv[2], argv[3], arg4, NullString );
1664
			ExtractFile(argv[2], argv[3], arg4, Utils::String::Null());
1583
		}
1665
		}
1584
	}
1666
	}
1585
	else if ( command == "-x" || command == "--extract")
1667
	else if ( command == "-x" || command == "--extract")
1586
	{
1668
	{
1587
		if ( argc < 4 )
1669
		if ( argc < 4 )
Line 1589... Line 1671...
1589
			printf ( "Syntax:\n\t%s -x <spkfile> <type> <filename> [destination]\n\tThis will extract a file from the package and save it to the corect path in <directory>\n\t<type> = %s\n", cmd.c_str(), fileTypes.c_str() );
1671
			printf ( "Syntax:\n\t%s -x <spkfile> <type> <filename> [destination]\n\tThis will extract a file from the package and save it to the corect path in <directory>\n\t<type> = %s\n", cmd.c_str(), fileTypes.c_str() );
1590
			printf ( "\t%s -x <multispkfile> <filename> [destination]\n\tThis will extract a spk file from the Multi-Spk package and save it to the destination path\n", cmd.c_str() );
1672
			printf ( "\t%s -x <multispkfile> <filename> [destination]\n\tThis will extract a spk file from the Multi-Spk package and save it to the destination path\n", cmd.c_str() );
1591
		}
1673
		}
1592
		else
1674
		else
1593
		{
1675
		{
1594
			CyString arg5, arg4;
1676
			Utils::String arg5, arg4;
1595
			if ( argc > 5 )
1677
			if ( argc > 5 )
1596
				arg5 = argv[5];
1678
				arg5 = argv[5];
1597
			if ( argc > 4 )
1679
			if ( argc > 4 )
1598
				arg4 = argv[4];
1680
				arg4 = argv[4];
1599
			ExtractFile ( argv[2], argv[3], arg4, arg5 );
1681
			ExtractFile(argv[2], argv[3], arg4, arg5);
1600
		}
1682
		}
1601
	}
1683
	}
1602
 
1684
 
1603
	// extracts all the files from an archive
1685
	// extracts all the files from an archive
1604
	else if ( command == "-e" || command == "--extractall" )
1686
	else if ( command == "-e" || command == "--extractall" )
Line 1608... Line 1690...
1608
		else
1690
		else
1609
		{
1691
		{
1610
			Utils::String arg4;
1692
			Utils::String arg4;
1611
			if ( argc > 4 )
1693
			if ( argc > 4 )
1612
				arg4 = argv[4];
1694
				arg4 = argv[4];
1613
			ExtractFiles(argv[2], arg4, atoi(argv[3]) );
1695
			ExtractFiles(argv[2], arg4, CBaseFile::GetGameFromString(argv[3]));
1614
		}
1696
		}
1615
	}
1697
	}
1616
 
1698
 
1617
	// creates a multispk archive
1699
	// creates a multispk archive
1618
	else if ( command == "-n" || command == "--createmulti" )
1700
	else if ( command == "-n" || command == "--createmulti" )