Subversion Repositories spk

Rev

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

Rev 306 Rev 307
Line 18... Line 18...
18
#ifdef _WIN32
18
#ifdef _WIN32
19
#include <windows.h>
19
#include <windows.h>
20
#include <direct.h>
20
#include <direct.h>
21
#include <shlobj.h>
21
#include <shlobj.h>
22
#endif
22
#endif
-
 
23
 
-
 
24
#include "Utils/CommandLine.h"
23
 
25
 
24
Utils::WString g_dir;
26
Utils::WString g_dir;
25
bool g_read;
27
bool g_read;
26
 
28
 
27
class CFileProgress : public CProgressInfo
29
class CFileProgress : public CProgressInfo
Line 104... Line 106...
104
*/
106
*/
105
void PrintSyntax(const Utils::WString &cmd)
107
void PrintSyntax(const Utils::WString &cmd)
106
{
108
{
107
	wprintf(L"Syntax: %s <command>\n", cmd.c_str() );
109
	wprintf(L"Syntax: %s <command>\n", cmd.c_str() );
108
	wprintf(L"Commands:\n" );
110
	wprintf(L"Commands:\n" );
109
	wprintf(L"\t-v <spkfile>\n\t--view <spkfile>\n\t\tViews the contents of a spk file\n\n" );
111
	wprintf(L"\t-v <spkfile>\n\t-view <spkfile>\n\t\tViews the contents of a spk file\n\n" );
110
	wprintf(L"\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" );
112
	wprintf(L"\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" );
111
	wprintf(L"\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" );
113
	wprintf(L"\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" );
112
	wprintf(L"\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" );
114
	wprintf(L"\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" );
113
	wprintf(L"\t-c <spkfile>\n\t--create\n\t\tCreates a new spk file\n\n" );
115
	wprintf(L"\t-c <spkfile>\n\t-create\n\t\tCreates a new spk file\n\n" );
114
	wprintf(L"\t-a <spkfile> <type> <filename>\n\t--append <spkfile> <type> <filename>\n\t\tAppends a file to the package of set <type>\n\n" );
116
	wprintf(L"\t-a <spkfile> <type> <filename>\n\t-append <spkfile> <type> <filename>\n\t\tAppends a file to the package of set <type>\n\n" );
115
	wprintf(L"\t-r <spkfile> <type> <filename>\n\t--remove <spkfile> <type> <filename>\n\t\tRemoves a file from the package of set <type>\n\n" );
117
	wprintf(L"\t-r <spkfile> <type> <filename>\n\t-remove <spkfile> <type> <filename>\n\t\tRemoves a file from the package of set <type>\n\n" );
116
	wprintf(L"\t-r <multispkfile> <filename>\n\t--removespk <multispkfile> <filename>\n\t\tRemoves a spk file from the Multi-SPK package\n\n" );
118
	wprintf(L"\t-r <multispkfile> <filename>\n\t-removespk <multispkfile> <filename>\n\t\tRemoves a spk file from the Multi-SPK package\n\n" );
117
	wprintf(L"\t-m <spkfile> <spkfile>\n\t--mergemulti <spkfile> <spkfile>\n\t\tMerges spk files together, the second file will be merged into the first\n\n" );
119
	wprintf(L"\t-m <spkfile> <spkfile>\n\t-mergemulti <spkfile> <spkfile>\n\t\tMerges spk files together, the second file will be merged into the first\n\n" );
118
	wprintf(L"\t-n <multispkfile>\n\t--createmulti\n\t\tCreates a multi spk file, and adds the spkfiles in\n\n" );
120
	wprintf(L"\t-n <multispkfile>\n\t-createmulti\n\t\tCreates a multi spk file, and adds the spkfiles in\n\n" );
119
	wprintf(L"\t-s <multispkfile> [destination]\n\t--splitmulti <multispkfile> [destination]\n\t\tSplits a Multi-SPK file up, saves all the spk files to Destination\n\n" );
121
	wprintf(L"\t-s <multispkfile> [destination]\n\t-splitmulti <multispkfile> [destination]\n\t\tSplits a Multi-SPK file up, saves all the spk files to Destination\n\n" );
120
	wprintf(L"\t--set <setting> [value]\n\t\tChanges the settings of the script\n\n" );
122
	wprintf(L"\t-set <spkfile> <setting> [value]\n\t\tChanges the settings of the script\n\n" );
121
	wprintf(L"\t--convertxsp <oldxsp> [newxsp]\n\t\tConverts an old XSP file into the new format\n\n");
123
	wprintf(L"\t-convertxsp <oldxsp> [newxsp]\n\t\tConverts an old XSP file into the new format\n\n");
122
	wprintf(L"\t--createscript <packagescript>\n\t\tCreates a spk file from a packager script\n\n");
124
	wprintf(L"\t-createscript <packagescript>\n\t\tCreates a spk file from a packager script\n\n");
123
	wprintf(L"\t--verifyscript <packagescript>\n\t\tChecks a packager script is valid without creating the resulting file\n\n");
125
	wprintf(L"\t-verifyscript <packagescript>\n\t\tChecks a packager script is valid without creating the resulting file\n\n");
124
	wprintf(L"\t--generatescript <package> [packagescript]\n\t\tCreates a packager script (.sps) from a spk file\n\n");
126
	wprintf(L"\t-generatescript <package> [packagescript]\n\t\tCreates a packager script (.sps) from a spk file\n\n");
125
	wprintf(L"\t--extractship <modfile> <xspfile> [shipid]\n\t\tCreates an XSP ship file from a mod package\n\n");
127
	wprintf(L"\t-extractship <modfile> <xspfile> [shipid]\n\t\tCreates an XSP ship file from a mod package\n\n");
126
	wprintf(L"\t--generateupdatefile <package>\n\t\tCreates an update file for the spk/xsp file\n\n");
128
	wprintf(L"\t-generateupdatefile <package>\n\t\tCreates an update file for the spk/xsp file\n\n");
127
	wprintf(L"\t--packagelist <filenames>\n\t\tThis will generate the update file to allow downloading packages from a server.\n\n");
129
	wprintf(L"\t-packagelist <filenames>\n\t\tThis will generate the update file to allow downloading packages from a server.\n\n");
128
	//	printf ( "\t--convertxspwizard <oldxsp> [newxsp]\n\t\tConverts an old XSP file into the new format\n\n");
130
	//	printf ( "\t-convertxspwizard <oldxsp> [newxsp]\n\t\tConverts an old XSP file into the new format\n\n");
129
}
131
}
130
 
132
 
131
void Settings(const Utils::WString &filename, const Utils::WString &settings, int argc, char **argv, const Utils::WString &cmd)
133
void Settings(const Utils::CommandLine &cmd)
132
{
134
{
-
 
135
	const Utils::WString &settings = cmd.arg(2);
-
 
136
	const Utils::WString &filename = cmd.arg(1);
133
	if ( settings.Compare(L"author") )
137
	if ( settings.Compare(L"author") )
134
	{
138
	{
135
		if ( argc < 5 )
139
		if (cmd.argCount() < 4)
136
		{
140
		{
137
			wprintf(L"Syntax: %s -set <spkfile> Author <authorname>\n\tSets the authors name of the package\n", cmd.c_str() );
141
			wprintf(L"Syntax: %s -set <spkfile> Author <authorname>\n\tSets the authors name of the package\n", cmd.cmdName().c_str());
138
			return;
142
			return;
139
		}
143
		}
140
	}
144
	}
141
	else
145
	else
142
	{
146
	{
Line 165... Line 169...
165
		}
169
		}
166
 
170
 
167
		// now do the settings
171
		// now do the settings
168
		if ( settings.Compare(L"author") )
172
		if ( settings.Compare(L"author") )
169
		{
173
		{
170
			spkfile.setAuthor(Utils::WString::FromString(argv[4]));
174
			spkfile.setAuthor(cmd.arg(3));
171
			wprintf(L"Settings Author to: %s\n", spkfile.author().c_str());
175
			wprintf(L"Settings Author to: %s\n", spkfile.author().c_str());
172
		}
176
		}
173
 
177
 
174
		spkfile.writeFile(filename);
178
		spkfile.writeFile(filename);
175
		printf ( "\nSPK file has been written sucessfully\n" );
179
		printf ( "\nSPK file has been written sucessfully\n" );
Line 422... Line 426...
422
	bool read = false;
426
	bool read = false;
423
	CBaseFile *pBaseFile = NULL;
427
	CBaseFile *pBaseFile = NULL;
424
 
428
 
425
	int check = CSpkFile::CheckFile ( filename );
429
	int check = CSpkFile::CheckFile ( filename );
426
	if ( check == SPKFILE_BASE )
430
	if ( check == SPKFILE_BASE )
427
	{
431
	{
428
		pBaseFile = new CBaseFile();
432
		pBaseFile = new CBaseFile();
429
		wprintf(L"* Opening SPK File, %s...\n", filename.c_str() );
433
		wprintf(L"* Opening SPK File, %s...\n", filename.c_str() );
430
		if ( !pBaseFile->readFile(filename, SPKREAD_NODATA))
434
		if ( !pBaseFile->readFile(filename, SPKREAD_NODATA))
431
		{
435
		{
432
			wprintf(L"Failed to open the spk files, %s\n", filename.c_str() );
436
			wprintf(L"Failed to open the spk files, %s\n", filename.c_str() );
Line 794... Line 798...
794
			pBaseFile->writeFile(sfile);
798
			pBaseFile->writeFile(sfile);
795
			wprintf(L"File has been written to disk successfully\n" );
799
			wprintf(L"File has been written to disk successfully\n" );
796
		}
800
		}
797
		else
801
		else
798
			wprintf(L"Unable to remove the file, %s, from the package\n", addfile.c_str());
802
			wprintf(L"Unable to remove the file, %s, from the package\n", addfile.c_str());
799
	}
803
	}
800
	else if ( check == SPKFILE_MULTI )
804
	else if ( check == SPKFILE_MULTI )
801
	{
805
	{
802
		CMultiSpkFile spkfile;
806
		CMultiSpkFile spkfile;
803
		wprintf(L"Opening Multi-SPK file, %s...", sfile.c_str());
807
		wprintf(L"Opening Multi-SPK file, %s...", sfile.c_str());
804
		if ( !spkfile.readFile(sfile))
808
		if ( !spkfile.readFile(sfile))
805
		{
809
		{
806
			wprintf(L"(Error)\nUnable to open the Multi-SPK file, %s\n", sfile.c_str());
810
			wprintf(L"(Error)\nUnable to open the Multi-SPK file, %s\n", sfile.c_str());
807
			return;
811
			return;
808
		}
812
		}
809
		wprintf(L"(Done)\n");
813
		wprintf(L"(Done)\n");
810
 
814
 
811
		const SMultiSpkFile *ms = spkfile.findFile(type);
815
		const SMultiSpkFile *ms = spkfile.findFile(type);
812
		if ( !ms )
816
		if ( !ms )
813
		{
817
		{
814
			wprintf(L"Unable to find the file \"%s\" in the package\n", type.c_str());
818
			wprintf(L"Unable to find the file \"%s\" in the package\n", type.c_str());
815
			return;
819
			return;
816
		}
820
		}
817
 
821
 
818
		wprintf(L"Removing file, %s, from Package\n", addfile.c_str());
822
		wprintf(L"Removing file, %s, from Package\n", addfile.c_str());
819
		if (!spkfile.removeFile(ms))
823
		if (!spkfile.removeFile(ms))
820
		{
824
		{
821
			wprintf(L"Error: Unable to remove file, %s, from package\n", type.c_str());
825
			wprintf(L"Error: Unable to remove file, %s, from package\n", type.c_str());
Line 825... Line 829...
825
		wprintf(L"Writing SPK File, %s... ", sfile.c_str());
829
		wprintf(L"Writing SPK File, %s... ", sfile.c_str());
826
		if (spkfile.writeFile(sfile))
830
		if (spkfile.writeFile(sfile))
827
			wprintf(L"(Done)\n");
831
			wprintf(L"(Done)\n");
828
		else
832
		else
829
			wprintf(L"(Error)\n");
833
			wprintf(L"(Error)\n");
830
	}
834
	}
831
	else
835
	else
832
		wprintf(L"Error: Invalid file format, unable to open\n");
836
		wprintf(L"Error: Invalid file format, unable to open\n");
833
}
837
}
834
 
838
 
835
 
839
 
836
void CreateMultiFile (const Utils::WString &filename)
840
void CreateMultiFile (const Utils::WString &filename)
837
{
841
{
838
	wprintf(L"* Creating new Multi-SPK File, %s\n\n", filename.c_str());
842
	wprintf(L"* Creating new Multi-SPK File, %s\n\n", filename.c_str());
839
 
843
 
840
	FILE *id = _wfopen(filename.c_str(), L"rb+");
844
	FILE *id = _wfopen(filename.c_str(), L"rb+");
841
	if ( id )
845
	if ( id )
842
	{
846
	{
843
		fclose ( id );
847
		fclose ( id );
844
		wprintf(L"* File already exists, unable to create\n");
848
		wprintf(L"* File already exists, unable to create\n");
845
		return;
849
		return;
846
	}
850
	}
847
 
851
 
848
	id = _wfopen(filename.c_str(), L"wb");
852
	id = _wfopen(filename.c_str(), L"wb");
849
	if ( !id )
853
	if ( !id )
850
	{
854
	{
851
		wprintf(L"* Unable to open file for writing\n");
855
		wprintf(L"* Unable to open file for writing\n");
852
		return;
856
		return;
853
	}
857
	}
854
	fclose(id);
858
	fclose(id);
855
	_wremove(filename.c_str());
859
	_wremove(filename.c_str());
856
 
860
 
857
	CMultiSpkFile spkfile;
861
	CMultiSpkFile spkfile;
858
 
862
 
859
	Utils::WString sInput;
863
	Utils::WString sInput;
860
	wprintf(L"Enter Multi-Spk Package Name: ");
864
	wprintf(L"Enter Multi-Spk Package Name: ");
Line 897... Line 901...
897
	else
901
	else
898
	{
902
	{
899
		wprintf(L"Writing MultiSpk file... ");
903
		wprintf(L"Writing MultiSpk file... ");
900
		if ( spkfile.writeFile(filename))
904
		if ( spkfile.writeFile(filename))
901
			wprintf(L"(Done)\n" );
905
			wprintf(L"(Done)\n" );
902
		else
906
		else
903
			wprintf(L"(Error)\n" );
907
			wprintf(L"(Error)\n" );
904
	}
908
	}
905
 
909
 
906
}
910
}
907
 
911
 
Line 945... Line 949...
945
	time_t now = time(NULL);
949
	time_t now = time(NULL);
946
 
950
 
947
	currDate = localtime( &now );
951
	currDate = localtime( &now );
948
	strftime(dateString, sizeof dateString, "%d %m %Y", currDate);
952
	strftime(dateString, sizeof dateString, "%d %m %Y", currDate);
949
	spkfile.setCreationDate(Utils::WString::FromString(dateString));
953
	spkfile.setCreationDate(Utils::WString::FromString(dateString));
950
 
954
 
951
	spkfile.writeFile(filename, NULL);
955
	spkfile.writeFile(filename, NULL);
952
	wprintf(L"SPK file has been written to disk: %s\n", filename.c_str() );
956
	wprintf(L"SPK file has been written to disk: %s\n", filename.c_str() );
953
}
957
}
954
 
958
 
955
void ExtractFiles (const Utils::WString &sfile, const Utils::WString &dir, int game )
959
void ExtractFiles (const Utils::WString &sfile, const Utils::WString &dir, int game )
Line 990... Line 994...
990
		}
994
		}
991
		wprintf(L"(Done)\n");
995
		wprintf(L"(Done)\n");
992
 
996
 
993
		if(game == 0)
997
		if(game == 0)
994
			wprintf(L"Extracting all files from archive...\n\n");
998
			wprintf(L"Extracting all files from archive...\n\n");
995
		else
999
		else
996
			wprintf(L"Extracting %s files from archive...\n\n", packages.GetGameExe()->gameNameFromType(game - 1).c_str());
1000
			wprintf(L"Extracting %s files from archive...\n\n", packages.GetGameExe()->gameNameFromType(game - 1).c_str());
997
 
1001
 
998
		CFileProgress info(&packages, pBaseFile, "Extracting");
1002
		CFileProgress info(&packages, pBaseFile, "Extracting");
999
		if (packages.extractAll(pBaseFile, dir, game, true, &info) )
1003
		if (packages.extractAll(pBaseFile, dir, game, true, &info) )
1000
			wprintf(L"\n(Done)\nFiles have been extracted successfully\n");
1004
			wprintf(L"\n(Done)\nFiles have been extracted successfully\n");
1001
		else
1005
		else
1002
			wprintf(L"\n(Error)\nThere was a problem extracting the files\n");
1006
			wprintf(L"\n(Error)\nThere was a problem extracting the files\n");
Line 1562... Line 1566...
1562
int main ( int argc, char **argv )
1566
int main ( int argc, char **argv )
1563
{
1567
{
1564
	// display program header to command prompt
1568
	// display program header to command prompt
1565
	printf ( "\nSPKTool V1.50 (SPK File Version %.2f) 14/02/2021 Created by Cycrow\n\n", (float)FILEVERSION );
1569
	printf ( "\nSPKTool V1.50 (SPK File Version %.2f) 14/02/2021 Created by Cycrow\n\n", (float)FILEVERSION );
1566
 
1570
 
1567
	// parse the cmd name
-
 
1568
	Utils::WString cmd (argv[0]);
1571
	Utils::CommandLine cmd(argc, argv);
1569
	cmd = cmd.findReplace(L"\\", L"/");
1572
	g_dir = cmd.cmdDir();
1570
	g_dir = cmd.tokens(L"/", 1, cmd.countToken(L"/") - 1);
-
 
1571
	cmd = cmd.token(L"/", cmd.countToken(L"/"));
-
 
1572
 
-
 
1573
	g_read = false;
1573
	g_read = false;
1574
 
1574
 
1575
	// not enough arguments, display the syntax and exit
1575
	// not enough arguments, display the syntax and exit
1576
	if ( argc < 2 )
1576
	if ( argc < 2 )
1577
	{
1577
	{
1578
		PrintSyntax ( cmd.toString() );
1578
		PrintSyntax(cmd.cmdName());
1579
		exit ( 1 );
1579
		exit ( 1 );
1580
	}
1580
	}
1581
 
1581
 
1582
	Utils::WString fileTypes;
1582
	Utils::WString fileTypes;
1583
	for ( int i = 0; i < FILETYPE_MAX; i++ )
1583
	for ( int i = 0; i < FILETYPE_MAX; i++ )
Line 1597... Line 1597...
1597
 
1597
 
1598
	// get the command flag
1598
	// get the command flag
1599
	Utils::WString command(argv[1]);
1599
	Utils::WString command(argv[1]);
1600
 
1600
 
1601
	// display the contents of the spk file
1601
	// display the contents of the spk file
1602
	if ( command == L"-v" || command == L"--view" || command == L"--version")
1602
	if ( command == L"-v" || command == L"-view" || command == L"-version")
1603
	{
1603
	{
1604
		if ( argc < 3 )
1604
		if ( argc < 3 )
1605
			wprintf(L"Syntax: %s -v <spkfile>\n\tWill open and display the contents of the spkfile\n", cmd.c_str() );
1605
			wprintf(L"Syntax: %s -v <spkfile>\n\tWill open and display the contents of the spkfile\n", cmd.cmdName().c_str());
1606
		else
1606
		else
1607
			DisplayVersion(argv[2]);
1607
			DisplayVersion(argv[2]);
1608
	}
1608
	}
1609
 
1609
 
1610
	// creates a new spk file
1610
	// creates a new spk file
1611
	else if ( command == L"-c" || command == L"--create" )
1611
	else if ( command == L"-c" || command == L"-create" )
1612
	{
1612
	{
1613
		if ( argc < 3 )
1613
		if ( argc < 3 )
1614
			wprintf(L"Syntax:\n\t%s -c <spkfile>\n\t%s --create <spkfile>\n\t\tThis will create a new SPK file and allow you to set some basic settings for the file\n", cmd.c_str(), cmd.c_str() );
1614
			wprintf(L"Syntax:\n\t%s -c <spkfile>\n\t%s -create <spkfile>\n\t\tThis will create a new SPK file and allow you to set some basic settings for the file\n", cmd.cmdName().c_str(), cmd.cmdName().c_str() );
1615
		else
1615
		else
1616
			CreateFile ( argv[2] );
1616
			CreateFile ( argv[2] );
1617
	}
1617
	}
1618
 
1618
 
1619
	// appends a file onto the spk archive
1619
	// appends a file onto the spk archive
1620
	else if ( command == L"-a" || command == L"--append" )
1620
	else if ( command == L"-a" || command == L"-append" )
1621
	{
1621
	{
1622
		if ( argc < 4 )
1622
		if ( argc < 4 )
1623
			wprintf(L"Syntax:\n\t%s -a <spkfile> <type> <filename>\n\t%s --append <spkfile> <type> <filename>\n\t\tThis will append the file into the archive and compress it according to the files default compression\n\t<type> = %s\n", cmd.c_str(), cmd.c_str(), fileTypes.c_str() );
1623
			wprintf(L"Syntax:\n\t%s -a <spkfile> <type> <filename>\n\t%s -append <spkfile> <type> <filename>\n\t\tThis will append the file into the archive and compress it according to the files default compression\n\t<type> = %s\n", cmd.cmdName().c_str(), cmd.cmdName().c_str(), fileTypes.c_str() );
1624
		else
1624
		else
1625
		{
1625
		{
1626
			Utils::WString arg4;
1626
			Utils::WString arg4;
1627
			if ( argc > 4 )
1627
			if ( argc > 4 )
1628
				arg4 = argv[4];
1628
				arg4 = argv[4];
1629
			AppendFile ( argv[2], argv[3], arg4 );
1629
			AppendFile ( argv[2], argv[3], arg4 );
1630
		}
1630
		}
1631
	}
1631
	}
1632
 
1632
 
1633
	// removes a file from the spk archive
1633
	// removes a file from the spk archive
1634
	else if ( command == L"-r" || command == L"--remove" || command == L"--removespk" )
1634
	else if ( command == L"-r" || command == L"-remove" || command == L"-removespk" )
1635
	{
1635
	{
1636
		if ( argc < 4 )
1636
		if ( argc < 4 )
1637
		{
1637
		{
1638
			wprintf(L"Syntax:\n\t%s -r <spkfile> <type> <filename>\n\t%s --remove <spkfile> <type> <filename\n\t\tThis will remove a file from the archive\n\t<type> = %s\n", cmd.c_str(), cmd.c_str(), fileTypes.c_str() );
1638
			wprintf(L"Syntax:\n\t%s -r <spkfile> <type> <filename>\n\t%s -remove <spkfile> <type> <filename\n\t\tThis will remove a file from the archive\n\t<type> = %s\n", cmd.cmdName().c_str(), cmd.cmdName().c_str(), fileTypes.c_str() );
1639
			wprintf(L"\t%s -r <multispkfile> <filename>\n\t%s --removespk <multispkfile> <filename>\n\t\tThis will remove a spk file from the Multi-SPK package\n", cmd.c_str(), cmd.c_str() );
1639
			wprintf(L"\t%s -r <multispkfile> <filename>\n\t%s -removespk <multispkfile> <filename>\n\t\tThis will remove a spk file from the Multi-SPK package\n", cmd.cmdName().c_str(), cmd.cmdName().c_str() );
1640
		}
1640
		}
1641
		else
1641
		else
1642
		{
1642
		{
1643
			Utils::WString arg4;
1643
			Utils::WString arg4;
1644
			if ( argc > 4 )
1644
			if ( argc > 4 )
Line 1646... Line 1646...
1646
			RemoveFile ( argv[2], argv[3], arg4 );
1646
			RemoveFile ( argv[2], argv[3], arg4 );
1647
		}
1647
		}
1648
	}
1648
	}
1649
 
1649
 
1650
	// extracts a file from a spk file
1650
	// extracts a file from a spk file
1651
	else if ( command == L"--extractspk" )
1651
	else if ( command == L"-extractspk" )
1652
	{
1652
	{
1653
		if ( argc < 4 )
1653
		if ( argc < 4 )
1654
			wprintf(L"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() );
1654
			wprintf(L"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.cmdName().c_str() );
1655
		else
1655
		else
1656
		{
1656
		{
1657
			Utils::WString arg4;
1657
			Utils::WString arg4;
1658
			if ( argc > 4 )
1658
			if ( argc > 4 )
1659
				arg4 = argv[3];
1659
				arg4 = argv[3];
1660
			ExtractFile(argv[2], argv[3], arg4, Utils::WString::Null());
1660
			ExtractFile(argv[2], argv[3], arg4, Utils::WString::Null());
1661
		}
1661
		}
1662
	}
1662
	}
1663
	else if ( command == L"-x" || command == L"--extract")
1663
	else if ( command == L"-x" || command == L"-extract")
1664
	{
1664
	{
1665
		if ( argc < 4 )
1665
		if ( argc < 4 )
1666
		{
1666
		{
1667
			wprintf(L"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() );
1667
			wprintf(L"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.cmdName().c_str(), fileTypes.c_str() );
1668
			wprintf(L"\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() );
1668
			wprintf(L"\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.cmdName().c_str() );
1669
		}
1669
		}
1670
		else
1670
		else
1671
		{
1671
		{
1672
			Utils::WString arg5, arg4;
1672
			Utils::WString arg5, arg4;
1673
			if ( argc > 5 )
1673
			if ( argc > 5 )
Line 1677... Line 1677...
1677
			ExtractFile(argv[2], argv[3], arg4, arg5);
1677
			ExtractFile(argv[2], argv[3], arg4, arg5);
1678
		}
1678
		}
1679
	}
1679
	}
1680
 
1680
 
1681
	// extracts all the files from an archive
1681
	// extracts all the files from an archive
1682
	else if ( command == L"-e" || command == L"--extractall" )
1682
	else if ( command == L"-e" || command == L"-extractall" )
1683
	{
1683
	{
1684
		if ( argc < 3 )
1684
		if ( argc < 3 )
1685
			wprintf(L"Syntax:\n\t%s -e <spkfile> [destination]\n\t--extractall <spkfile> <game> [destination]\n\t\tThis will extract all files of a set game into the destination directory\n\n\t\tGame = 0 will extract all files", cmd.c_str() );
1685
			wprintf(L"Syntax:\n\t%s -e <spkfile> [destination]\n\t-extractall <spkfile> <game> [destination]\n\t\tThis will extract all files of a set game into the destination directory\n\n\t\tGame = 0 will extract all files", cmd.cmdName().c_str() );
1686
		else
1686
		else
1687
		{
1687
		{
1688
			Utils::WString arg4;
1688
			Utils::WString arg4;
1689
			if ( argc > 4 )
1689
			if ( argc > 4 )
1690
				arg4 = argv[4];
1690
				arg4 = argv[4];
1691
			ExtractFiles(argv[2], arg4, CBaseFile::GetGameFromString(argv[3]));
1691
			ExtractFiles(argv[2], arg4, CBaseFile::GetGameFromString(argv[3]));
1692
		}
1692
		}
1693
	}
1693
	}
1694
 
1694
 
1695
	// creates a multispk archive
1695
	// creates a multispk archive
1696
	else if ( command == L"-n" || command == L"--createmulti" )
1696
	else if ( command == L"-n" || command == L"-createmulti" )
1697
	{
1697
	{
1698
		if ( argc < 3 )
1698
		if ( argc < 3 )
1699
			wprintf(L"Syntax:\n\t%s -n <multispkfile>\n\t%s --createmulti <multispkfile>\n\t\tThis will create a multispk file and allow you to add spk files to it\n", cmd.c_str(), cmd.c_str() );
1699
			wprintf(L"Syntax:\n\t%s -n <multispkfile>\n\t%s -createmulti <multispkfile>\n\t\tThis will create a multispk file and allow you to add spk files to it\n", cmd.cmdName().c_str(), cmd.cmdName().c_str() );
1700
		else
1700
		else
1701
			CreateMultiFile ( argv[2] );
1701
			CreateMultiFile ( argv[2] );
1702
	}
1702
	}
1703
 
1703
 
1704
	// merges 2 multi-spk archives together, or appends a single spk file into a multi-spk file
1704
	// merges 2 multi-spk archives together, or appends a single spk file into a multi-spk file
1705
	else if ( command == L"-m" || command == L"--mergemulti" )
1705
	else if ( command == L"-m" || command == L"-mergemulti" )
1706
	{
1706
	{
1707
		if ( argc < 4 )
1707
		if ( argc < 4 )
1708
			wprintf(L"Syntax:\n\t%s -m <spkfile1> <spkfile2>\n\t%s --mergemulti <;spkfile1>; <;spkfile2&gt;\n\t\tThis will add spkfile2 into spkfile1, if spkfile1 is a normal SPK file, it will be saved into a Multi-Spk file\nspkfile2 can also be a Multi-Spk file, all files within it will be added\n", cmd.c_str(), cmd.c_str() );
1708
			wprintf(L"Syntax:\n\t%s -m <spkfile1> <spkfile2>\n\t%s -mergemulti <;spkfile1>; <;spkfile2&gt;\n\t\tThis will add spkfile2 into spkfile1, if spkfile1 is a normal SPK file, it will be saved into a Multi-Spk file\nspkfile2 can also be a Multi-Spk file, all files within it will be added\n", cmd.cmdName().c_str(), cmd.cmdName().c_str() );
1709
		else
1709
		else
1710
			AppendMultiFile ( argv[2], argv[3] );
1710
			AppendMultiFile ( argv[2], argv[3] );
1711
	}
1711
	}
1712
 
1712
 
1713
	// splits the multi-spk file, exracts all spk files
1713
	// splits the multi-spk file, exracts all spk files
1714
	else if ( command == L"-s" || command == L"--splitmulti" )
1714
	else if ( command == L"-s" || command == L"-splitmulti" )
1715
	{
1715
	{
1716
		if ( argc < 3 )
1716
		if ( argc < 3 )
1717
			wprintf(L"Syntax: %s -s <multispkfile> [destination]\n\tSplits the Multi-SPK file and saves each spk file to the destiantion directory\n", cmd.c_str() );
1717
			wprintf(L"Syntax: %s -s <multispkfile> [destination]\n\tSplits the Multi-SPK file and saves each spk file to the destiantion directory\n", cmd.cmdName().c_str() );
1718
		else
1718
		else
1719
		{
1719
		{
1720
			Utils::WString arg3;
1720
			Utils::WString arg3;
1721
			if ( argc > 3 )
1721
			if ( argc > 3 )
1722
				arg3 = argv[3];
1722
				arg3 = argv[3];
1723
			SplitMulti ( argv[2], arg3 );
1723
			SplitMulti ( argv[2], arg3 );
1724
		}
1724
		}
1725
	}
1725
	}
1726
 
1726
 
1727
	else if ( command == L"--set" )
1727
	else if ( command == L"-set" )
1728
	{
1728
	{
1729
		if ( argc < 4 )
1729
		if ( argc < 4 )
1730
			wprintf(L"Syntax: %s --set <spkfile> <setting> [values]\n\tSets various settings in the package\n", cmd.c_str() );
1730
			wprintf(L"Syntax: %s -set <spkfile> <setting> [values]\n\tSets various settings in the package\n", cmd.cmdName().c_str() );
1731
		else
1731
		else
1732
			Settings(argv[2], argv[3], argc, argv, cmd);
1732
			Settings(cmd);
1733
	}
1733
	}
1734
	else if ( command == L"--setrating" )
1734
	else if ( command == L"-setrating" )
1735
	{
1735
	{
1736
		if ( argc < 6 )
1736
		if ( argc < 6 )
1737
			wprintf(L"Syntax: %s --setrating <spkfile> <easeofuse> <gamechanging> <recommended>\n\tSets the rating of the spk package\n", cmd.c_str() );
1737
			wprintf(L"Syntax: %s -setrating <spkfile> <easeofuse> <gamechanging> <recommended>\n\tSets the rating of the spk package\n", cmd.cmdName().c_str() );
1738
		else
1738
		else
1739
			SetRating(argv[2], Utils::WString(argv[3]).toInt(), Utils::WString(argv[4]).toInt(), Utils::WString(argv[5]).toInt());
1739
			SetRating(argv[2], Utils::WString(argv[3]).toInt(), Utils::WString(argv[4]).toInt(), Utils::WString(argv[5]).toInt());
1740
	}
1740
	}
1741
	else if ( command == L"--convertxsp" || command == L"--convertxspwizard" )
1741
	else if ( command == L"-convertxsp" || command == L"-convertxspwizard" )
1742
	{
1742
	{
1743
		if ( argc < 3 )
1743
		if ( argc < 3 )
1744
			wprintf(L"Syntax: %s %s <xspfile> [newxspfile]\n\tConverts an old format xsp file to work with the new format\n", cmd.c_str(), command.c_str() );
1744
			wprintf(L"Syntax: %s %s <xspfile> [newxspfile]\n\tConverts an old format xsp file to work with the new format\n", cmd.cmdName().c_str(), command.c_str());
1745
		else
1745
		else
1746
		{
1746
		{
1747
			Utils::WString arg3;
1747
			Utils::WString arg3;
1748
			if ( argc > 3 )
1748
			if ( argc > 3 )
1749
				arg3 = argv[3];
1749
				arg3 = argv[3];
1750
			ConvertXsp(Utils::WString::FromString(argv[2]), arg3, (command == L"--convertxspwizard") ? true : false);
1750
			ConvertXsp(Utils::WString::FromString(argv[2]), arg3, (command == L"-convertxspwizard") ? true : false);
1751
		}
1751
		}
1752
	}
1752
	}
1753
	else if ( command == L"--createscript" )
1753
	else if ( command == L"-createscript" )
1754
	{
1754
	{
1755
		if ( argc < 3 )
1755
		if ( argc < 3 )
1756
			wprintf(L"Syntax:\n\t%s --createscript <packagerscript>\n\t\tThis will create a spk/xsp file from a packager script\n", cmd.c_str() );
1756
			wprintf(L"Syntax:\n\t%s -createscript <packagerscript>\n\t\tThis will create a spk/xsp file from a packager script\n", cmd.cmdName().c_str() );
1757
		else
1757
		else
1758
			LoadPackagerScript ( argv[2], false );
1758
			LoadPackagerScript ( argv[2], false );
1759
	}
1759
	}
1760
	else if ( command == L"--generatescript" )
1760
	else if ( command == L"-generatescript" )
1761
	{
1761
	{
1762
		if ( argc < 3 )
1762
		if ( argc < 3 )
1763
			wprintf(L"Syntax:\n\t%s --generatescript <package> [packagerscript]\n\t\tThis will generate a packager script file from a spk/xsp file.\n", cmd.c_str() );
1763
			wprintf(L"Syntax:\n\t%s -generatescript <package> [packagerscript]\n\t\tThis will generate a packager script file from a spk/xsp file.\n", cmd.cmdName().c_str() );
1764
		else
1764
		else
1765
		{
1765
		{
1766
			if ( argc < 4 )
1766
			if ( argc < 4 )
1767
				GeneratePackagerScript ( argv[2], "", 0);
1767
				GeneratePackagerScript ( argv[2], "", 0);
1768
			else
1768
			else
1769
				GeneratePackagerScript ( argv[2], argv[3], 0);
1769
				GeneratePackagerScript ( argv[2], argv[3], 0);
1770
		}
1770
		}
1771
	}
1771
	}
1772
	else if ( command == L"--verifyscript" )
1772
	else if ( command == L"-verifyscript" )
1773
	{
1773
	{
1774
		if ( argc < 3 )
1774
		if ( argc < 3 )
1775
			wprintf(L"Syntax:\n\t%s --verifyscript <packagerscript>\n\t\tThis will read a packager script and check its correct without creating the resulting spk/xsp file\n", cmd.c_str() );
1775
			wprintf(L"Syntax:\n\t%s -verifyscript <packagerscript>\n\t\tThis will read a packager script and check its correct without creating the resulting spk/xsp file\n", cmd.cmdName().c_str() );
1776
		else
1776
		else
1777
			LoadPackagerScript ( argv[2], true );
1777
			LoadPackagerScript ( argv[2], true );
1778
	}
1778
	}
1779
	else if ( command == L"--extractship" )
1779
	else if ( command == L"-extractship" )
1780
	{
1780
	{
1781
		if ( argc < 4 )
1781
		if ( argc < 4 )
1782
			wprintf(L"Syntax:\n\t%s --extractship <modfile> <xspfile> [shipid]\n\t\tThis will create an xsp ship file by extracting from a mod file\n", cmd.c_str() );
1782
			wprintf(L"Syntax:\n\t%s -extractship <modfile> <xspfile> [shipid]\n\t\tThis will create an xsp ship file by extracting from a mod file\n", cmd.cmdName().c_str() );
1783
		else
1783
		else
1784
		{
1784
		{
1785
			if ( argc < 5 )
1785
			if ( argc < 5 )
1786
				ExtractShip ( argv[2], argv[3], L"" );
1786
				ExtractShip ( argv[2], argv[3], L"" );
1787
			else
1787
			else
1788
				ExtractShip ( argv[2], argv[3], argv[4] );
1788
				ExtractShip ( argv[2], argv[3], argv[4] );
1789
		}
1789
		}
1790
	}
1790
	}
1791
	else if (command == L"--generateupdatefile")
1791
	else if (command == L"-generateupdatefile")
1792
	{
1792
	{
1793
		if (argc < 3)
1793
		if (argc < 3)
1794
			wprintf(L"Syntax:\n\t%s --generateupdatefile <package>\n\t\tThis will generate the update file to allow auto updates for a package\n", cmd.c_str());
1794
			wprintf(L"Syntax:\n\t%s -generateupdatefile <package>\n\t\tThis will generate the update file to allow auto updates for a package\n", cmd.cmdName().c_str());
1795
		else
1795
		else
1796
			GenerateUpdateFile(argv[2]);
1796
			GenerateUpdateFile(argv[2]);
1797
	}
1797
	}
1798
	else if (command == L"--packagelist")
1798
	else if (command == L"-packagelist")
1799
	{
1799
	{
1800
		if (argc < 3)
1800
		if (argc < 3)
1801
			wprintf(L"Syntax:\n\t%s --packagelist <filenames>\n\t\tThis will generate the update file to allow downloading packages from a server.\n", cmd.c_str());
1801
			wprintf(L"Syntax:\n\t%s -packagelist <filenames>\n\t\tThis will generate the update file to allow downloading packages from a server.\n", cmd.cmdName().c_str());
1802
		else
1802
		else
1803
			GenerateUpdateList(argc, argv);
1803
			GenerateUpdateList(argc, argv);
1804
	}
1804
	}
1805
 
1805
 
1806
	// not a valid switch, display syntax
1806
	// not a valid switch, display syntax
1807
	else
1807
	else
1808
		PrintSyntax(cmd);
1808
		PrintSyntax(cmd.cmdName());
1809
 
1809
 
1810
#ifdef _DEBUG
1810
#ifdef _DEBUG
1811
	char pause;
1811
	char pause;
1812
	scanf ( "%s", &pause );
1812
	scanf ( "%s", &pause );
1813
#endif
1813
#endif