Subversion Repositories spk

Rev

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

Rev 294 Rev 298
Line 25... Line 25...
25
bool g_read;
25
bool g_read;
26
 
26
 
27
class CFileProgress : public CProgressInfo
27
class CFileProgress : public CProgressInfo
28
{
28
{
29
private:
29
private:
30
	Utils::String _display;
30
	Utils::WString _display;
31
	CBaseFile *_package;
31
	CBaseFile *_package;
32
	CPackages *_packages;
32
	CPackages *_packages;
33
 
33
 
34
public:
34
public:
35
	CFileProgress(CPackages *packages, CBaseFile *package, const Utils::String &display) : 
35
	CFileProgress(CPackages *packages, CBaseFile *package, const Utils::WString &display) : 
36
		_display(display),
36
		_display(display),
37
		_packages(packages),
37
		_packages(packages),
38
		_package(package)
38
		_package(package)
39
	{
39
	{
40
 
40
 
Line 67... Line 67...
67
				}
67
				}
68
			}
68
			}
69
		}
69
		}
70
 
70
 
71
		if(game.empty())
71
		if(game.empty())
72
			wprintf(L"%hs: %s\n", _display.c_str(), file->getNameDirectory(_package).c_str());
72
			wprintf(L"%s: %s\n", _display.c_str(), file->getNameDirectory(_package).c_str());
73
		else
73
		else
74
			wprintf(L"%hs: %s [%s]\n", _display.c_str(), file->getNameDirectory(_package).c_str(), game.c_str());
74
			wprintf(L"%s: %s [%s]\n", _display.c_str(), file->getNameDirectory(_package).c_str(), game.c_str());
75
	}
75
	}
76
 
76
 
77
};
77
};
78
 
78
 
79
/*
79
/*
Line 82... Line 82...
82
*/
82
*/
83
Utils::WString GetInput ()
83
Utils::WString GetInput ()
84
{
84
{
85
	g_read = true;
85
	g_read = true;
86
 
86
 
87
	Utils::String line;
87
	Utils::WString line;
88
	char c = getchar();
88
	wchar_t c = getchar();
89
 
89
 
90
	while ( (c != '\n') && (c != '\0') )
90
	while ( (c != L'\n') && (c != L'\0') )
91
	{
91
	{
92
		line += c;
92
		line += c;
93
		c = getchar();
93
		c = getchar();
94
	}
94
	}
95
 
95
 
96
	return line.toWString();
96
	return line;
97
}
97
}
98
 
98
 
99
 
99
 
100
/*
100
/*
101
	Func:	PrintSyntax
101
	Func:	PrintSyntax
102
	Args:	String cmd - The command name to be displayed
102
	Args:	String cmd - The command name to be displayed
103
	Desc:	Displays the syntax for the program
103
	Desc:	Displays the syntax for the program
104
*/
104
*/
105
void PrintSyntax ( CyString cmd )
105
void PrintSyntax(const Utils::WString &cmd)
106
{
106
{
107
	printf ( "Syntax: %s <command>\n", cmd.c_str() );
107
	wprintf(L"Syntax: %s <command>\n", cmd.c_str() );
108
	printf ( "Commands:\n" );
108
	wprintf(L"Commands:\n" );
109
	printf ( "\t-v <spkfile>\n\t--view <spkfile>\n\t\tViews the contents of a spk file\n\n" );
109
	wprintf(L"\t-v <spkfile>\n\t--view <spkfile>\n\t\tViews the contents of a spk file\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" );
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" );
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" );
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" );
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" );
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" );
113
	printf ( "\t-c <spkfile>\n\t--create\n\t\tCreates a new spk file\n\n" );
113
	wprintf(L"\t-c <spkfile>\n\t--create\n\t\tCreates a new spk file\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" );
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" );
115
	printf ( "\t-r <spkfile> <type> <filename>\n\t--remove <spkfile> <type> <filename>\n\t\tRemoves a file from 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" );
116
	printf ( "\t-r <multispkfile> <filename>\n\t--removespk <multispkfile> <filename>\n\t\tRemoves a spk file from the Multi-SPK package\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" );
117
	printf ( "\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" );
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" );
118
	printf ( "\t-n <multispkfile>\n\t--createmulti\n\t\tCreates a multi spk file, and adds the spkfiles in\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" );
119
	printf ( "\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" );
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" );
120
	printf ( "\t--set <setting> [value]\n\t\tChanges the settings of the script\n\n" );
120
	wprintf(L"\t--set <setting> [value]\n\t\tChanges the settings of the script\n\n" );
121
	printf ( "\t--convertxsp <oldxsp> [newxsp]\n\t\tConverts an old XSP file into the new format\n\n");
121
	wprintf(L"\t--convertxsp <oldxsp> [newxsp]\n\t\tConverts an old XSP file into the new format\n\n");
122
	printf ( "\t--createscript <packagescript>\n\t\tCreates a spk file from a packager script\n\n");
122
	wprintf(L"\t--createscript <packagescript>\n\t\tCreates a spk file from a packager script\n\n");
123
	printf ( "\t--verifyscript <packagescript>\n\t\tChecks a packager script is valid without creating the resulting file\n\n");
123
	wprintf(L"\t--verifyscript <packagescript>\n\t\tChecks a packager script is valid without creating the resulting file\n\n");
124
	printf ( "\t--generatescript <package> [packagescript]\n\t\tCreates a packager script (.sps) from a spk file\n\n");
124
	wprintf(L"\t--generatescript <package> [packagescript]\n\t\tCreates a packager script (.sps) from a spk file\n\n");
125
	printf ( "\t--extractship <modfile> <xspfile> [shipid]\n\t\tCreates an XSP ship file from a mod package\n\n");
125
	wprintf(L"\t--extractship <modfile> <xspfile> [shipid]\n\t\tCreates an XSP ship file from a mod package\n\n");
126
	printf ( "\t--generateupdatefile <package>\n\t\tCreates an update file for the spk/xsp file\n\n");
126
	wprintf(L"\t--generateupdatefile <package>\n\t\tCreates an update file for the spk/xsp file\n\n");
127
	printf ( "\t--packagelist <filenames>\n\t\tThis will generate the update file to allow downloading packages from a server.\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");
128
	//	printf ( "\t--convertxspwizard <oldxsp> [newxsp]\n\t\tConverts an old XSP file into the new format\n\n");
128
	//	printf ( "\t--convertxspwizard <oldxsp> [newxsp]\n\t\tConverts an old XSP file into the new format\n\n");
129
}
129
}
130
 
130
 
131
void Settings(const Utils::WString &filename, const Utils::WString &settings, int argc, char **argv, const Utils::WString &cmd)
131
void Settings(const Utils::WString &filename, const Utils::WString &settings, int argc, char **argv, const Utils::WString &cmd)
132
{
132
{
Line 176... Line 176...
176
	}
176
	}
177
	else
177
	else
178
		wprintf(L"File, %s, is not a valid SPK file\n", filename.c_str() );
178
		wprintf(L"File, %s, is not a valid SPK file\n", filename.c_str() );
179
}
179
}
180
 
180
 
181
void SetRating ( CyString filename, int ease, int changing, int rec )
181
void SetRating (const Utils::WString &filename, int ease, int changing, int rec )
182
{
182
{
183
	if ( ease > 5 )
183
	if ( ease > 5 )
184
		ease = 5;
184
		ease = 5;
185
	if ( changing > 5 )
185
	if ( changing > 5 )
186
		changing = 5;
186
		changing = 5;
187
	if ( changing > 5 )
187
	if ( changing > 5 )
188
		changing = 5;
188
		changing = 5;
189
 
189
 
190
	FILE *id = fopen ( filename.c_str(), ";rb+" );
190
	FILE *id = _wfopen(filename.c_str(), L";rb+");
191
	if ( !id )
191
	if ( !id )
192
	{
192
	{
193
		printf ( "Error: File, %s, doesn't exist\n", filename.c_str() );
193
		wprintf(L"Error: File, %s, doesn't exist\n", filename.c_str() );
194
		return;
194
		return;
195
	}
195
	}
196
	fclose ( id );
196
	fclose ( id );
197
 
197
 
198
	int check = CSpkFile::CheckFile(filename.ToString());
198
	int check = CSpkFile::CheckFile(filename);
199
	if ( check == SPKFILE_SINGLE )
199
	if ( check == SPKFILE_SINGLE )
200
	{
200
	{
201
		CSpkFile spkfile;
201
		CSpkFile spkfile;
202
		printf ( "* Opening SPK File, %s...\n", filename.c_str() );
202
		wprintf(L"* Opening SPK File, %s...\n", filename.c_str() );
203
		if ( !spkfile.readFile(filename.ToString(), SPKREAD_ALL))
203
		if ( !spkfile.readFile(filename, SPKREAD_ALL))
204
		{
204
		{
205
			printf ( "Failed to open the spk files, %s\n", filename.c_str() );
205
			wprintf(L"Failed to open the spk files, %s\n", filename.c_str() );
206
			return;
206
			return;
207
		}
207
		}
208
 
208
 
209
		printf("File Format Version: %.2f\n", spkfile.fileVersion());
209
		wprintf(L"File Format Version: %.2f\n", spkfile.fileVersion());
210
 
210
 
211
		printf ( "Assigning Ease Of Use:\t\t%d\nAssigning Game Changing:\t%d\nAssigning Recommended:\t\t%d\n", ease, changing, rec);
211
		wprintf(L"Assigning Ease Of Use:\t\t%d\nAssigning Game Changing:\t%d\nAssigning Recommended:\t\t%d\n", ease, changing, rec);
212
		spkfile.setEaseOfUse(ease);
212
		spkfile.setEaseOfUse(ease);
213
		spkfile.setGameChanging(changing);
213
		spkfile.setGameChanging(changing);
214
		spkfile.setRecommended(rec);
214
		spkfile.setRecommended(rec);
215
		spkfile.writeFile(filename.ToString());
215
		spkfile.writeFile(filename);
216
		printf ( "\nSPK file has been written sucessfully\n" );
216
		wprintf(L"\nSPK file has been written sucessfully\n" );
217
 
-
 
218
	}
217
	}
219
	else
218
	else
220
		printf ( "File, %s, is not a valid SPK file\n", filename.c_str() );
219
		wprintf(L"File, %s, is not a valid SPK file\n", filename.c_str() );
221
}
220
}
222
 
221
 
223
Utils::WString GetTerranConflictDir()
222
Utils::WString GetTerranConflictDir()
224
{
223
{
225
	while ( true )
224
	while ( true )
Line 236... Line 235...
236
	}
235
	}
237
 
236
 
238
	return Utils::WString::Null();
237
	return Utils::WString::Null();
239
}
238
}
240
 
239
 
241
void ConvertXsp(const Utils::WString &filename, const Utils::String &tofile, bool wizard)
240
void ConvertXsp(const Utils::WString &filename, const Utils::WString &tofile, bool wizard)
242
{
241
{
243
	// first chekc if file even exists
242
	// first chekc if file even exists
244
	FILE *id = _wfopen (filename.c_str(), L"rb+" );
243
	FILE *id = _wfopen (filename.c_str(), L"rb+" );
245
	if ( !id )
244
	if ( !id )
246
	{
245
	{
Line 272... Line 271...
272
			if (!dir.empty())
271
			if (!dir.empty())
273
			{
272
			{
274
			}
273
			}
275
		}
274
		}
276
 
275
 
277
		printf ( "* Writing XSP File, %s... ", tofile.c_str() );
276
		wprintf(L"* Writing XSP File, %s... ", tofile.c_str());
278
		// now we need to save it
277
		// now we need to save it
279
		if ( !xspFile.writeFile(tofile) )
278
		if ( !xspFile.writeFile(tofile) )
280
			printf ( "[ERROR]\n\nFailed to write file to, %s\n", tofile.c_str() );
279
			wprintf(L"[ERROR]\n\nFailed to write file to, %s\n", tofile.c_str() );
281
		else
280
		else
282
			wprintf(L"[DONE]\n\nFile: %s, has been converted to, %hs\n", filename.c_str(), tofile.c_str() );
281
			wprintf(L"[DONE]\n\nFile: %s, has been converted to, %s\n", filename.c_str(), tofile.c_str() );
283
	}
282
	}
284
	else
283
	else
285
		wprintf(L"Error: File, %s, is not an old style XSP file\n", filename.c_str() );
284
		wprintf(L"Error: File, %s, is not an old style XSP file\n", filename.c_str() );
286
}
285
}
287
 
286
 
288
void ExtractShip(const Utils::String &catfile, const Utils::String &to, Utils::WString shipid)
287
void ExtractShip(const Utils::WString &catfile, const Utils::WString &to, Utils::WString shipid)
289
{
288
{
290
	if ( !CFileIO::Exists(catfile) )
289
	if ( !CFileIO::Exists(catfile) )
291
	{
290
	{
292
		printf ( "Error: Mod File, %s, does not exist\n", catfile.c_str() );
291
		wprintf(L"Error: Mod File, %s, does not exist\n", catfile.c_str());
293
		return;
292
		return;
294
	}
293
	}
295
 
294
 
296
	CVirtualFileSystem *pVfs = new CVirtualFileSystem();
295
	CVirtualFileSystem *pVfs = new CVirtualFileSystem();
297
	if ( !pVfs->loadMod(catfile) ) {
296
	if ( !pVfs->loadMod(catfile) ) {
298
		printf("Error: Unable to read mod file, %s\n", catfile.c_str());
297
		wprintf(L"Error: Unable to read mod file, %s\n", catfile.c_str());
299
		delete pVfs;
298
		delete pVfs;
300
		return;
299
		return;
301
	}
300
	}
302
 
301
 
303
	Utils::WStringList *ships = pVfs->getTShipsEntries();
302
	Utils::WStringList *ships = pVfs->getTShipsEntries();
304
	if ( !ships )
303
	if ( !ships )
305
	{
304
	{
306
		printf("Error: Failed to read %s::types\\TShips.pck\n", catfile.c_str());
305
		wprintf(L"Error: Failed to read %s::types\\TShips.pck\n", catfile.c_str());
307
		delete pVfs;
306
		delete pVfs;
308
		return;
307
		return;
309
	}
308
	}
310
 
309
 
311
	// now get the ship line to extract
310
	// now get the ship line to extract
Line 347... Line 346...
347
		delete pVfs;
346
		delete pVfs;
348
		return;
347
		return;
349
	}
348
	}
350
 
349
 
351
	// now we have the tships to use, lets start to extract the ship
350
	// now we have the tships to use, lets start to extract the ship
352
	wprintf(L"Extracting ship from %hs, Ship=%s\n", catfile.c_str(), tShipsLine.token(L";", -2).c_str());
351
	wprintf(L"Extracting ship from %s, Ship=%s\n", catfile.c_str(), tShipsLine.token(L";", -2).c_str());
353
 
352
 
354
	CXspFile ship;
353
	CXspFile ship;
355
	if ( ship.extractShip(pVfs, tShipsLine.token(L";", -2).toString(), 0))
354
	if ( ship.extractShip(pVfs, tShipsLine.token(L";", -2).toString(), 0))
356
	{
355
	{
357
		printf ( "Ship has been successfully extracted\n" );
356
		printf ( "Ship has been successfully extracted\n" );
Line 378... Line 377...
378
		time_t now = time(NULL);
377
		time_t now = time(NULL);
379
		currDate = localtime( &now );
378
		currDate = localtime( &now );
380
		strftime(dateString, sizeof dateString, "%d/%m/%Y", currDate);
379
		strftime(dateString, sizeof dateString, "%d/%m/%Y", currDate);
381
		ship.setCreationDate(Utils::WString::FromString(dateString));
380
		ship.setCreationDate(Utils::WString::FromString(dateString));
382
 
381
 
383
		printf("\nWriting file: %s...\n", to.c_str());
382
		wprintf(L"\nWriting file: %s...\n", to.c_str());
384
		if ( ship.writeFile(to) )
383
		if ( ship.writeFile(to) )
385
			printf("Ship file has been created: %s\n", to.c_str());
384
			wprintf(L"Ship file has been created: %s\n", to.c_str());
386
		else
385
		else
387
			printf("Error: Unable to write ship file, %s\n", to.c_str());
386
			wprintf(L"Error: Unable to write ship file, %s\n", to.c_str());
388
	}
387
	}
389
	else
388
	else
390
		printf("Error: Unable to extract the ship\n");
389
		wprintf(L"Error: Unable to extract the ship\n");
391
 
390
 
392
	delete pVfs;
391
	delete pVfs;
393
}
392
}
394
 
393
 
395
CyString GetGameName(int game)
394
Utils::WString GetGameName(int game)
396
{
395
{
397
	switch(game)
396
	switch(game)
398
	{
397
	{
399
		case GAME_X2:
398
		case GAME_X2:
400
			return "X2: The Threat";
399
			return L"X2: The Threat";
401
		case GAME_X3:
400
		case GAME_X3:
402
			return "X3: Reunion";
401
			return L"X3: Reunion";
403
		case GAME_X3TC:
402
		case GAME_X3TC:
404
			return "X3: Terran Conflict";
403
			return L"X3: Terran Conflict";
405
		case GAME_X3AP:
404
		case GAME_X3AP:
406
			return "X3: Albion Prelude";
405
			return L"X3: Albion Prelude";
407
		case GAME_X3FL:
406
		case GAME_X3FL:
408
			return "X3: Farnham's Legacy";
407
			return L"X3: Farnham's Legacy";
409
	}
408
	}
410
	return "Unknown";
409
	return L"Unknown";
411
}
410
}
412
void DisplayVersion(const Utils::String &filename)
411
void DisplayVersion(const Utils::WString &filename)
413
{
412
{
414
	// first chekc if file even exists
413
	// first chekc if file even exists
415
	FILE *id = fopen ( filename.c_str(), ";rb+" );
414
	FILE *id = _wfopen(filename.c_str(), L";rb+");
416
	if ( !id )
415
	if ( !id )
417
	{
416
	{
418
		printf ( "Error: File, %s, doesn't exist\n", filename.c_str() );
417
		wprintf(L"Error: File, %s, doesn't exist\n", filename.c_str());
419
		return;
418
		return;
420
	}
419
	}
421
	fclose ( id );
420
	fclose ( id );
422
 
421
 
423
	bool read = false;
422
	bool read = false;
Line 425... Line 424...
425
 
424
 
426
	int check = CSpkFile::CheckFile ( filename );
425
	int check = CSpkFile::CheckFile ( filename );
427
	if ( check == SPKFILE_BASE )
426
	if ( check == SPKFILE_BASE )
428
	{
427
	{
429
		pBaseFile = new CBaseFile();
428
		pBaseFile = new CBaseFile();
430
		printf ( "* Opening SPK File, %s...\n", filename.c_str() );
429
		wprintf(L"* Opening SPK File, %s...\n", filename.c_str() );
431
		if ( !pBaseFile->readFile(filename, SPKREAD_NODATA))
430
		if ( !pBaseFile->readFile(filename, SPKREAD_NODATA))
432
		{
431
		{
433
			printf ( "Failed to open the spk files, %s\n", filename.c_str() );
432
			wprintf(L"Failed to open the spk files, %s\n", filename.c_str() );
434
			return;
433
			return;
435
		}
434
		}
436
		read = true;
435
		read = true;
437
	}
436
	}
438
	else if ( check == SPKFILE_SINGLE )
437
	else if ( check == SPKFILE_SINGLE )
439
	{
438
	{
440
		pBaseFile = (CBaseFile *)new CSpkFile();
439
		pBaseFile = (CBaseFile *)new CSpkFile();
441
		printf ( "* Opening SPK File, %s...\n", filename.c_str() );
440
		wprintf(L"* Opening SPK File, %s...\n", filename.c_str() );
442
		if ( !pBaseFile->readFile(filename, SPKREAD_NODATA))
441
		if ( !pBaseFile->readFile(filename, SPKREAD_NODATA))
443
		{
442
		{
444
			printf ( "Failed to open the spk files, %s\n", filename.c_str() );
443
			wprintf(L"Failed to open the spk files, %s\n", filename.c_str() );
445
			return;
444
			return;
446
		}
445
		}
447
		read = true;
446
		read = true;
448
	}
447
	}
449
	else if ( check == SPKFILE_SINGLESHIP )
448
	else if ( check == SPKFILE_SINGLESHIP )
450
	{
449
	{
451
		pBaseFile = (CBaseFile *)new CXspFile();
450
		pBaseFile = (CBaseFile *)new CXspFile();
452
		printf ( "* Opening XSP File, %s...\n", filename.c_str() );
451
		wprintf(L"* Opening XSP File, %s...\n", filename.c_str() );
453
		if ( !pBaseFile->readFile(filename, SPKREAD_NODATA))
452
		if ( !pBaseFile->readFile(filename, SPKREAD_NODATA))
454
		{
453
		{
455
			printf ( "Failed to open the xsp files, %s\n", filename.c_str() );
454
			wprintf(L"Failed to open the xsp files, %s\n", filename.c_str() );
456
			return;
455
			return;
457
		}
456
		}
458
		read = true;
457
		read = true;
459
	}
458
	}
460
	// otherwise its an old ship file
459
	// otherwise its an old ship file
461
	else if ( CFileIO(filename).isFileExtension(L"xsp") )
460
	else if ( CFileIO(filename).isFileExtension(L"xsp") )
462
	{
461
	{
463
		printf ( "* Converting XSP File, %s...\n", filename.c_str() );
462
		wprintf(L"* Converting XSP File, %s...\n", filename.c_str() );
464
		pBaseFile = new CXspFile;
463
		pBaseFile = new CXspFile;
465
		if ( !((CXspFile *)pBaseFile)->convertOld(filename) )
464
		if ( !((CXspFile *)pBaseFile)->convertOld(filename) )
466
		{
465
		{
467
			delete pBaseFile;
466
			delete pBaseFile;
468
			pBaseFile = NULL;
467
			pBaseFile = NULL;
469
			printf ( "Failed to convert old xsp file, %s\n", filename.c_str() );
468
			wprintf(L"Failed to convert old xsp file, %s\n", filename.c_str() );
470
			return;
469
			return;
471
		}
470
		}
472
		check = SPKFILE_SINGLESHIP;
471
		check = SPKFILE_SINGLESHIP;
473
		read = true;
472
		read = true;
474
	}
473
	}
475
 
474
 
476
	if ( pBaseFile && read)
475
	if ( pBaseFile && read)
477
	{
476
	{
478
		CPackages p;
477
		CPackages p;
479
		p.startup(L".", L".", L".");
478
		p.startup(L".", L".", L".");
480
 
479
 
481
		CSpkFile *pSpkFile = NULL;
480
		CSpkFile *pSpkFile = NULL;
482
		CXspFile *pXspFile = NULL;
481
		CXspFile *pXspFile = NULL;
483
		if ( check == SPKFILE_SINGLE )
482
		if ( check == SPKFILE_SINGLE )
484
			pSpkFile = (CSpkFile *)pBaseFile;
483
			pSpkFile = (CSpkFile *)pBaseFile;
485
		else
484
		else
486
			pXspFile = (CXspFile *)pBaseFile;
485
			pXspFile = (CXspFile *)pBaseFile;
487
 
486
 
488
		printf("File Format Version: %.2f\n", pBaseFile->fileVersion());
487
		wprintf(L"File Format Version: %.2f\n", pBaseFile->fileVersion());
489
 
488
 
490
		Utils::WString sType;
489
		Utils::WString sType;
491
		if ( check == SPKFILE_SINGLESHIP )
490
		if ( check == SPKFILE_SINGLESHIP )
492
			sType = L"Ship";
491
			sType = L"Ship";
493
		else
492
		else
Line 507... Line 506...
507
		else
506
		else
508
			wprintf(L"%s", p.getGameTypesString(pBaseFile, true).c_str());
507
			wprintf(L"%s", p.getGameTypesString(pBaseFile, true).c_str());
509
		printf("\n");
508
		printf("\n");
510
 
509
 
511
		if ( pXspFile )
510
		if ( pXspFile )
512
		{
511
		{
513
			wprintf(L"Ship Display Name: %s\n", pXspFile->shipName(44).c_str());
512
			wprintf(L"Ship Display Name: %s\n", pXspFile->shipName(44).c_str());
514
			if ( pXspFile->IsExistingShip() )
513
			if ( pXspFile->IsExistingShip() )
515
				wprintf(L"Ship ID: %s (Replace Existing Ship)\n", pXspFile->shipID().c_str() );
514
				wprintf(L"Ship ID: %s (Replace Existing Ship)\n", pXspFile->shipID().c_str() );
516
			else
515
			else
517
				wprintf(L"Ship ID: %s\n", pXspFile->shipID().c_str() );
516
				wprintf(L"Ship ID: %s\n", pXspFile->shipID().c_str() );
518
 
517
 
519
			if ( pXspFile->anyShipyards() )
518
			if ( pXspFile->anyShipyards() )
520
			{
519
			{
521
				printf ( "Add To Shipyards:\n" );
520
				printf ( "Add To Shipyards:\n" );
522
				for (unsigned long i = 1; i <= GetMaxShipyards(); i *= 2 )
521
				for (unsigned long i = 1; i <= GetMaxShipyards(); i *= 2 )
523
				{
522
				{
524
					if ( pXspFile->isShipyard(static_cast<ShipyardRace>(i)) )
523
					if ( pXspFile->isShipyard(static_cast<ShipyardRace>(i)) )
525
						wprintf(L"\t%s\n", GetShipyardName(static_cast<ShipyardRace>(i)).c_str());
524
						wprintf(L"\t%s\n", GetShipyardName(static_cast<ShipyardRace>(i)).c_str());
526
				}
525
				}
527
			}
526
			}
528
 
527
 
529
			for ( SWeaponMask *text = pXspFile->GetLaserMasks()->First(); text; text = pXspFile->GetLaserMasks()->Next() )
528
			for ( SWeaponMask *text = pXspFile->GetLaserMasks()->First(); text; text = pXspFile->GetLaserMasks()->Next() )
530
				printf ( "Laser Mask, Game: %s, Mask: %d\n", GetGameName(text->iGame).c_str(), text->iMask);
529
				wprintf(L"Laser Mask, Game: %s, Mask: %d\n", GetGameName(text->iGame).c_str(), text->iMask);
531
			for ( SWeaponMask *text = pXspFile->GetMissileMasks()->First(); text; text = pXspFile->GetMissileMasks()->Next() )
530
			for ( SWeaponMask *text = pXspFile->GetMissileMasks()->First(); text; text = pXspFile->GetMissileMasks()->Next() )
532
				printf ( "Missile Mask, Game: %s, Mask: %d\n", GetGameName(text->iGame).c_str(), text->iMask);
531
				wprintf(L"Missile Mask, Game: %s, Mask: %d\n", GetGameName(text->iGame).c_str(), text->iMask);
533
 
532
 
534
			if ( pXspFile->GetOriginalDescription() )
533
			if ( pXspFile->GetOriginalDescription() )
535
				printf("Use Existing Text, ID: %d\n", pXspFile->GetOriginalDescription());
534
				wprintf(L"Use Existing Text, ID: %d\n", pXspFile->GetOriginalDescription());
536
 
535
 
537
			if ( pXspFile->AnyTexts() )
536
			if ( pXspFile->AnyTexts() )
538
			{
537
			{
539
				for ( SText *text = pXspFile->GetTexts()->First(); text; text = pXspFile->GetTexts()->Next() )
538
				for ( SText *text = pXspFile->GetTexts()->First(); text; text = pXspFile->GetTexts()->Next() )
540
				{
539
				{
541
					printf("Ship Text, Language: %d\n", text->iId);
540
					wprintf(L"Ship Text, Language: %d\n", text->iId);
542
					if ( !text->sName.empty() )
541
					if ( !text->sName.empty() )
543
						wprintf(L"\tName: %s\n", text->sName.c_str());
542
						wprintf(L"\tName: %s\n", text->sName.c_str());
544
					if ( !text->sDesc.empty() )
543
					if ( !text->sDesc.empty() )
545
						wprintf(L"\tDescription: %s\n", text->sDesc.c_str());
544
						wprintf(L"\tDescription: %s\n", text->sDesc.c_str());
546
				}
545
				}
547
			}
546
			}
548
 
547
 
549
			if ( pXspFile->AnyComponents() )
548
			if ( pXspFile->AnyComponents() )
550
			{
549
			{
551
				printf ( "Component Entries:\n" );
550
				wprintf(L"Component Entries:\n" );
552
				for ( SComponent *c = pXspFile->GetComponents()->First(); c; c = pXspFile->GetComponents()->Next() )
551
				for ( SComponent *c = pXspFile->GetComponents()->First(); c; c = pXspFile->GetComponents()->Next() )
553
					wprintf(L"\t%s\n\t\t%s\n\t\t\t%s\n", c->sSection.c_str(), c->sSection2.c_str(), c->sData.c_str());
552
					wprintf(L"\t%s\n\t\t%s\n\t\t\t%s\n", c->sSection.c_str(), c->sSection2.c_str(), c->sData.c_str());
554
			}
553
			}
555
			if ( pXspFile->AnyDummies() )
554
			if ( pXspFile->AnyDummies() )
556
			{
555
			{
557
				printf ( "Dummy Entries:\n" );
556
				wprintf(L"Dummy Entries:\n" );
558
				for ( SDummy *d = pXspFile->GetDummies()->First(); d; d = pXspFile->GetDummies()->Next() )
557
				for ( SDummy *d = pXspFile->GetDummies()->First(); d; d = pXspFile->GetDummies()->Next() )
559
					wprintf(L"\t%s\n\t\t%s\n", d->sSection.c_str(), d->sData.c_str());
558
					wprintf(L"\t%s\n\t\t%s\n", d->sSection.c_str(), d->sData.c_str());
560
			}
559
			}
561
			if ( pXspFile->AnyCockpits() )
560
			if ( pXspFile->AnyCockpits() )
562
			{
561
			{
563
				printf ( "Cockpit Entries:\n" );
562
				wprintf(L"Cockpit Entries:\n" );
564
				for ( SCockpit *c = pXspFile->GetCockpits()->First(); c; c = pXspFile->GetCockpits()->Next() )
563
				for ( SCockpit *c = pXspFile->GetCockpits()->First(); c; c = pXspFile->GetCockpits()->Next() )
565
					wprintf(L"\t%s\n", c->sCockpit.c_str());
564
					wprintf(L"\t%s\n", c->sCockpit.c_str());
566
			}
565
			}
567
			if ( pXspFile->anyCutData() )
566
			if ( pXspFile->anyCutData() )
568
			{
567
			{
569
				printf ( "CutData Entries [%d]:\n", pXspFile->getCutData().size() );
568
				wprintf(L"CutData Entries [%d]:\n", pXspFile->getCutData().size() );
570
				for(auto itr = pXspFile->getCutData().begin(); itr != pXspFile->getCutData().end(); itr++)
569
				for(auto itr = pXspFile->getCutData().begin(); itr != pXspFile->getCutData().end(); itr++)
571
					wprintf(L"\t%s\n", (*itr)->str.c_str());
570
					wprintf(L"\t%s\n", (*itr)->str.c_str());
572
			}
571
			}
573
		}
572
		}
574
 
573
 
Line 608... Line 607...
608
			printf("Update Mirror Addresses:\n");
607
			printf("Update Mirror Addresses:\n");
609
			for (size_t i = 0; i < pBaseFile->getMaxWebMirrors(); i++ )
608
			for (size_t i = 0; i < pBaseFile->getMaxWebMirrors(); i++ )
610
				wprintf(L"\t%s\n", pBaseFile->getWebMirror(i).c_str());
609
				wprintf(L"\t%s\n", pBaseFile->getWebMirror(i).c_str());
611
		}
610
		}
612
		if ( pSpkFile )
611
		if ( pSpkFile )
613
		{
612
		{
614
			if ( (!pSpkFile->otherName().empty()) && (!pSpkFile->otherAuthor().empty()) )
613
			if ( (!pSpkFile->otherName().empty()) && (!pSpkFile->otherAuthor().empty()) )
615
				wprintf(L"Script is a child to the mod: %s by %s\n", pSpkFile->otherName().c_str(), pSpkFile->otherAuthor().c_str() );
614
				wprintf(L"Script is a child to the mod: %s by %s\n", pSpkFile->otherName().c_str(), pSpkFile->otherAuthor().c_str() );
616
		}
615
		}
617
 
616
 
618
		if ( pBaseFile->AnyDependacies() )
617
		if ( pBaseFile->AnyDependacies() )
Line 654... Line 653...
654
						wprintf(L"\t\t%s (%s) Size: %s\n", file->getNameDirectory(pBaseFile).c_str(), file->fileTypeString().c_str(), file->dataSizeString().c_str());
653
						wprintf(L"\t\t%s (%s) Size: %s\n", file->getNameDirectory(pBaseFile).c_str(), file->fileTypeString().c_str(), file->dataSizeString().c_str());
655
 
654
 
656
					}
655
					}
657
				}
656
				}
658
			}
657
			}
659
 
658
 
660
		}
659
		}
661
		else
660
		else
662
			printf ( "\nThere are currently no files in the package\n" );
661
			printf ( "\nThere are currently no files in the package\n" );
663
	}
662
	}
664
	else if ( check == SPKFILE_MULTI )
663
	else if ( check == SPKFILE_MULTI )
665
	{
664
	{
666
		CMultiSpkFile spkfile;
665
		CMultiSpkFile spkfile;
667
		printf ( "* Opening Multi-SPK file, %s...\n", filename.c_str() );
666
		wprintf(L"* Opening Multi-SPK file, %s...\n", filename.c_str() );
668
		if ( !pBaseFile->readFile(filename, false))
667
		if ( !pBaseFile->readFile(filename, false))
669
		{
668
		{
670
			printf ( "Error: Failed to open the Multi-SPK file, %s\n", filename.c_str() );
669
			wprintf(L"Error: Failed to open the Multi-SPK file, %s\n", filename.c_str() );
671
			return;
670
			return;
672
		}
671
		}
673
 
672
 
674
		wprintf(L"Multi Package Name: %s\n", spkfile.name().c_str() );
673
		wprintf(L"Multi Package Name: %s\n", spkfile.name().c_str() );
675
		printf ( "Selection Mode: " );
674
		wprintf(L"Selection Mode: " );
676
		if (spkfile.isSelection ())
675
		if (spkfile.isSelection ())
677
			printf ( "On\n" );
676
			wprintf(L"On\n" );
678
		else
677
		else
679
			printf ( "Off\n" );
678
			wprintf(L"Off\n" );
680
 
679
 
681
		CLinkList<SMultiSpkFile> *list = spkfile.GetFileList();
680
		CLinkList<SMultiSpkFile> *list = spkfile.GetFileList();
682
		for ( SMultiSpkFile *ms = list->First(); ms; ms = list->Next() )
681
		for ( SMultiSpkFile *ms = list->First(); ms; ms = list->Next() )
683
		{
682
		{
684
			wprintf(L"File, %s:\n", ms->sName.c_str() );
683
			wprintf(L"File, %s:\n", ms->sName.c_str() );
685
			wprintf(L"\tSize: %s\n", SPK::GetSizeString (ms->lSize).c_str() );
684
			wprintf(L"\tSize: %s\n", SPK::GetSizeString (ms->lSize).c_str() );
686
			if ( (!ms->sScriptName.empty()) && (!ms->sScriptAuthor.empty()) )
685
			if ( (!ms->sScriptName.empty()) && (!ms->sScriptAuthor.empty()) )
687
				wprintf(L"\tScript: %s %s by %s\n", ms->sScriptName.c_str(), ms->sScriptVersion.c_str(), ms->sScriptAuthor.c_str() );
686
				wprintf(L"\tScript: %s %s by %s\n", ms->sScriptName.c_str(), ms->sScriptVersion.c_str(), ms->sScriptAuthor.c_str() );
688
			printf ( "\tDefault Install: " );
687
			wprintf(L"\tDefault Install: " );
689
			if ( ms->bOn )
688
			if ( ms->bOn )
690
				printf ( "Yes\n" );
689
				wprintf(L"Yes\n" );
691
			else
690
			else
692
				printf ( "No\n" );
691
				wprintf(L"No\n" );
693
		}
692
		}
694
	}
693
	}
695
	else
694
	else
696
		printf ( "File, %s, is not a valid SPK file\n", filename.c_str() );
695
		wprintf(L"File, %s, is not a valid SPK file\n", filename.c_str() );
697
 
696
 
698
	if ( pBaseFile )
697
	if ( pBaseFile )
699
		delete pBaseFile;
698
		delete pBaseFile;
700
}
699
}
701
 
700
 
702
void AppendFile ( CyString sfile, CyString type, CyString addfile )
701
void AppendFile (const Utils::WString &sfile, const Utils::WString &type, const Utils::WString &addfile )
703
{
702
{
704
	int t = GetFileTypeFromString(type.ToString());
703
	int t = GetFileTypeFromString(type);
705
	if ( t == -1 )
704
	if ( t == -1 )
706
	{
705
	{
707
		printf ( "The file type \&quot;%s\" is invalid\n", type.c_str() );
706
		wprintf(L"The file type \&quot;%s\" is invalid\n", type.c_str());
708
		return;
707
		return;
709
	}
708
	}
710
 
709
 
711
	int check = CSpkFile::CheckFile(sfile.ToString());
710
	int check = CSpkFile::CheckFile(sfile);
712
	CBaseFile *pBaseFile = 0;
711
	CBaseFile *pBaseFile = 0;
713
	if ( check == SPKFILE_SINGLE )
712
	if ( check == SPKFILE_SINGLE )
714
		pBaseFile = new CSpkFile();
713
		pBaseFile = new CSpkFile();
715
	else if ( check == SPKFILE_SINGLESHIP )
714
	else if ( check == SPKFILE_SINGLESHIP )
716
		pBaseFile = new CXspFile();
715
		pBaseFile = new CXspFile();
717
	else if ( check == SPKFILE_BASE )
716
	else if ( check == SPKFILE_BASE )
718
		pBaseFile = new CBaseFile();
717
		pBaseFile = new CBaseFile();
719
 
718
 
720
	if ( !pBaseFile )
719
	if ( !pBaseFile )
721
	{
720
	{
722
		printf ( ";Error: Invalid file format, unable to open\n" );
721
		wprintf(L";Error: Invalid file format, unable to open\n");
723
		return;
722
		return;
724
	}
723
	}
725
 
724
 
726
	printf ( ";Opening File, %s... ", sfile.c_str() );
725
	wprintf(L";Opening File, %s... ", sfile.c_str());
727
	if ( !pBaseFile->readFile(sfile.ToString()))
726
	if ( !pBaseFile->readFile(sfile))
728
	{
727
	{
729
		printf ( "(Error)\nUnable to open the file, %s\n", sfile.c_str() );
728
		wprintf(L"(Error)\nUnable to open the file, %s\n", sfile.c_str());
730
		return;
729
		return;
731
	}
730
	}
732
	printf ( "(Done)\n" );
731
	wprintf(L"(Done)\n" );
733
 
732
 
734
	MyProgress progress(0);
733
	MyProgress progress(0);
735
 
734
 
736
	printf ( "Adding file %s to package\n\t>", addfile.c_str() );
735
	wprintf(L"Adding file %s to package\n\t>", addfile.c_str() );
737
 
736
 
738
	if ( pBaseFile->appendFile(addfile.ToString(), t, 0, false, Utils::String::Null(), &progress))
737
	if ( pBaseFile->appendFile(addfile, t, 0, false, Utils::WString::Null(), &progress))
739
	{
738
	{
740
		progress.PrintDone();
739
		progress.PrintDone();
741
		printf ( "&lt; (Done)\n" );
740
		wprintf(L"&lt; (Done)\n");
742
 
741
 
743
		pBaseFile->writeFile(sfile.ToString());
742
		pBaseFile->writeFile(sfile);
744
		printf ( "\nFile has been written sucessfully\n" );
743
		wprintf(L"\nFile has been written sucessfully\n");
745
	}
744
	}
746
	else
745
	else
747
		printf ( "&lt; (Error)\n" );
746
		wprintf(L"&lt; (Error)\n");
748
}
747
}
749
 
748
 
750
void RemoveFile ( CyString sfile, CyString type, CyString addfile )
749
void RemoveFile(const Utils::WString &sfile, const Utils::WString &type, const Utils::WString &addfile)
751
{
750
{
752
	FILE *id = fopen ( sfile.c_str(), ";rb+" );
751
	FILE *id = _wfopen(sfile.c_str(), L";rb+");
753
	if ( !id )
752
	if ( !id )
754
	{
753
	{
755
		printf ( "Error: File, %s, doesn't exist\n", sfile.c_str() );
754
		wprintf(L"Error: File, %s, doesn't exist\n", sfile.c_str() );
756
		return;
755
		return;
757
	}
756
	}
758
 
757
 
759
	if ( addfile.Empty() )
758
	if ( addfile.empty() )
760
	{
759
	{
761
		printf ( "Error: Remove filename is invalid\n" );
760
		wprintf(L"Error: Remove filename is invalid\n" );
762
		return;
761
		return;
763
	}
762
	}
764
	FileType t = GetFileTypeFromString(type.ToString());
763
	FileType t = GetFileTypeFromString(type);
765
	if (t == FileType::FILETYPE_UNKNOWN)
764
	if (t == FileType::FILETYPE_UNKNOWN)
766
	{
765
	{
767
		printf ( "The file type \"%s\" is invalid\n", type.c_str() );
766
		wprintf(L"The file type \"%s\" is invalid\n", type.c_str() );
768
		return;
767
		return;
769
	}
768
	}
770
 
769
 
771
	int check = CSpkFile::CheckFile(sfile.ToString());
770
	int check = CSpkFile::CheckFile(sfile);
772
	CBaseFile *pBaseFile = 0;
771
	CBaseFile *pBaseFile = 0;
773
	if ( check == SPKFILE_SINGLE )
772
	if ( check == SPKFILE_SINGLE )
774
		pBaseFile = new CSpkFile();
773
		pBaseFile = new CSpkFile();
775
	else if ( check == SPKFILE_SINGLESHIP )
774
	else if ( check == SPKFILE_SINGLESHIP )
776
		pBaseFile = new CXspFile();
775
		pBaseFile = new CXspFile();
777
	else if ( check == SPKFILE_BASE )
776
	else if ( check == SPKFILE_BASE )
778
		pBaseFile = new CBaseFile();
777
		pBaseFile = new CBaseFile();
779
 
778
 
780
	if ( pBaseFile )
779
	if ( pBaseFile )
781
	{
780
	{
782
		printf ( ";Opening File, %s... ", sfile.c_str() );
781
		wprintf(L";Opening File, %s... ", sfile.c_str());
783
		if ( !pBaseFile->readFile(sfile.ToString()))
782
		if ( !pBaseFile->readFile(sfile))
784
		{
783
		{
785
			printf ( "(Error)\nUnable to open the file, %s\n", sfile.c_str() );
784
			wprintf(L"(Error)\nUnable to open the file, %s\n", sfile.c_str());
786
			return;
785
			return;
787
		}
786
		}
788
		printf ( "(Done)\n" );
787
		wprintf(L"(Done)\n");
789
 
788
 
790
		printf ( ";Removing file, %s, from Package\n", addfile.c_str() );
789
		wprintf(L";Removing file, %s, from Package\n", addfile.c_str());
791
 
790
 
792
		if(pBaseFile->removeFile(addfile.ToString(), t))
791
		if(pBaseFile->removeFile(addfile, t))
793
		{
792
		{
794
			printf ( "File, %s, has been remove from package\n", addfile.c_str() );
793
			wprintf(L"File, %s, has been remove from package\n", addfile.c_str() );
795
			pBaseFile->writeFile(sfile.ToString());
794
			pBaseFile->writeFile(sfile);
796
			printf ( "File has been written to disk successfully\n" );
795
			wprintf(L"File has been written to disk successfully\n" );
797
		}
796
		}
798
		else
797
		else
799
			printf ( "Unable to remove the file, %s, from the package\n", addfile.c_str() );
798
			wprintf(L"Unable to remove the file, %s, from the package\n", addfile.c_str());
800
	}
799
	}
801
	else if ( check == SPKFILE_MULTI )
800
	else if ( check == SPKFILE_MULTI )
802
	{
801
	{
803
		CMultiSpkFile spkfile;
802
		CMultiSpkFile spkfile;
804
		printf ( "Opening Multi-SPK file, %s...", sfile.c_str() );
803
		wprintf(L"Opening Multi-SPK file, %s...", sfile.c_str());
805
		if ( !spkfile.readFile(sfile.ToString()))
804
		if ( !spkfile.readFile(sfile))
806
		{
805
		{
807
			printf ( "(Error)\nUnable to open the Multi-SPK file, %s\n", sfile.c_str() );
806
			wprintf(L"(Error)\nUnable to open the Multi-SPK file, %s\n", sfile.c_str());
808
			return;
807
			return;
809
		}
808
		}
810
		printf ( "(Done)\n" );
809
		wprintf(L"(Done)\n");
811
 
810
 
812
		const SMultiSpkFile *ms = spkfile.findFile ( type.ToString() );
811
		const SMultiSpkFile *ms = spkfile.findFile(type);
813
		if ( !ms )
812
		if ( !ms )
814
		{
813
		{
815
			printf ( "Unable to find the file \"%s\" in the package\n", type.c_str() );
814
			wprintf(L"Unable to find the file \"%s\" in the package\n", type.c_str());
816
			return;
-
 
817
		}
-
 
818
 
-
 
819
		printf ( "Removing file, %s, from Package\n", addfile.c_str() );
-
 
820
		if (!spkfile.removeFile(ms))
-
 
821
		{
-
 
822
			printf ( "Error: Unable to remove file, %s, from package\n", type.c_str() );
-
 
823
			return;
815
			return;
824
		}
816
		}
825
 
817
 
-
 
818
		wprintf(L"Removing file, %s, from Package\n", addfile.c_str());
-
 
819
		if (!spkfile.removeFile(ms))
-
 
820
		{
-
 
821
			wprintf(L"Error: Unable to remove file, %s, from package\n", type.c_str());
-
 
822
			return;
-
 
823
		}
-
 
824
 
826
		printf ( "Writing SPK File, %s... ", sfile.c_str() );
825
		wprintf(L"Writing SPK File, %s... ", sfile.c_str());
827
		if (spkfile.writeFile(sfile.ToString()))
826
		if (spkfile.writeFile(sfile))
828
			printf ( "(Done)\n" );
827
			wprintf(L"(Done)\n");
829
		else
828
		else
830
			printf ( "(Error)\n" );
829
			wprintf(L"(Error)\n");
831
	}
830
	}
832
	else
831
	else
833
		printf ( ";Error: Invalid file format, unable to open\n" );
832
		wprintf(L";Error: Invalid file format, unable to open\n");
834
}
833
}
835
 
834
 
836
 
835
 
837
void CreateMultiFile ( CyString filename )
836
void CreateMultiFile (const Utils::WString &filename)
838
{
837
{
839
	printf ( "* Creating new Multi-SPK File, %s\n\n", filename.c_str() );
838
	wprintf(L"* Creating new Multi-SPK File, %s\n\n", filename.c_str());
840
 
839
 
841
	FILE *id = fopen ( filename.c_str(), ";rb+" );
840
	FILE *id = _wfopen(filename.c_str(), L";rb+");
842
	if ( id )
841
	if ( id )
843
	{
842
	{
844
		fclose ( id );
843
		fclose ( id );
845
		printf ( ";* File already exists, unable to create\n" );
844
		wprintf(L";* File already exists, unable to create\n");
846
		return;
845
		return;
847
	}
846
	}
848
 
847
 
849
	id = fopen ( filename.c_str(), ";wb" );
848
	id = _wfopen(filename.c_str(), L";wb");
850
	if ( !id )
849
	if ( !id )
851
	{
850
	{
852
		printf ( ";* Unable to open file for writing\n" );
851
		wprintf(L";* Unable to open file for writing\n");
853
		return;
852
		return;
854
	}
853
	}
855
	fclose ( id );
854
	fclose(id);
856
	remove ( filename.c_str() );
855
	_wremove(filename.c_str());
857
 
856
 
858
	CMultiSpkFile spkfile;
857
	CMultiSpkFile spkfile;
859
 
858
 
860
	Utils::WString sInput;
859
	Utils::WString sInput;
861
	printf ( ";Enter Multi-Spk Package Name: " );
860
	wprintf(L";Enter Multi-Spk Package Name: ");
862
	spkfile.setName(GetInput().toString());
861
	spkfile.setName(GetInput());
863
 
862
 
864
	while ( true )
863
	while ( true )
865
	{
864
	{
866
		printf ( "\nDo you want users to select scripts to install? (Y/N): " );
865
		wprintf(L"\nDo you want users to select scripts to install? (Y/N): " );
867
		Utils::WString i = GetInput();
866
		Utils::WString i = GetInput();
868
		i = i.upper();
867
		i = i.upper();
869
		if ( i == L"Y" )
868
		if ( i == L"Y" )
870
			spkfile.setSelection(true);
869
			spkfile.setSelection(true);
871
		if ( (i == L"Y") || (i == L"N") )
870
		if ( (i == L"Y") || (i == L"N") )
872
			break;
871
			break;
873
	}
872
	}
874
 
873
 
875
	while ( true )
874
	while ( true )
876
	{
875
	{
877
		printf ( "\nEnter Spk File to add (Enter \"0\" to finish): " );
876
		wprintf(L"\nEnter Spk File to add (Enter \"0\" to finish): " );
878
		sInput = GetInput();
877
		sInput = GetInput();
879
		if ( sInput == L"0" )
878
		if ( sInput == L"0" )
880
			break;
879
			break;
881
 
880
 
882
		// check if file can be opened
881
		// check if file can be opened
883
		FILE *id2 = fopen ( sInput.toString().c_str(), "rb+");
882
		FILE *id2 = _wfopen(sInput.c_str(), L"rb+");
884
		if ( !id2 )
883
		if ( !id2 )
885
			wprintf(L"Error: Unable to open SPK file %s\n", sInput.c_str() );
884
			wprintf(L"Error: Unable to open SPK file %s\n", sInput.c_str() );
886
		else
885
		else
887
		{
886
		{
888
			fclose ( id2 );
887
			fclose(id2);
889
			if ( !spkfile.addFile(sInput.toString()))
888
			if ( !spkfile.addFile(sInput))
890
				printf ( ";Error: Unable to add SPK file to package\n" );
889
				wprintf(L";Error: Unable to add SPK file to package\n");
891
			else
890
			else
892
				wprintf(L"File Added to package (%s)\n", sInput.c_str() );
891
				wprintf(L"File Added to package (%s)\n", sInput.c_str());
893
		}
892
		}
894
	}
893
	}
895
 
894
 
896
	if ( spkfile.numFiles() < 1 )
895
	if ( spkfile.numFiles() < 1 )
897
		printf ( "\nError: You have added no files, you must add at least one file to create a package\n" );
896
		wprintf(L"\nError: You have added no files, you must add at least one file to create a package\n");
898
	else
897
	else
899
	{
898
	{
900
		printf ( "Writing MultiSpk file... " );
899
		wprintf(L"Writing MultiSpk file... ");
901
		if ( spkfile.writeFile(filename.ToString()))
900
		if ( spkfile.writeFile(filename))
902
			printf ( "(Done)\n" );
901
			wprintf(L"(Done)\n" );
903
		else
902
		else
904
			printf ( "(Error)\n" );
903
			wprintf(L"(Error)\n" );
905
	}
904
	}
906
 
905
 
907
}
906
}
908
 
-
 
909
void CreateFile ( CyString filename )
-
 
910
{
-
 
911
	printf ( "* Creating new SPK File, %s\n\n", filename.c_str() );
-
 
912
 
907
 
-
 
908
void CreateFile(const Utils::WString &filename)
-
 
909
{
-
 
910
	wprintf(L"* Creating new SPK File, %s\n\n", filename.c_str());
-
 
911
 
913
	FILE *id = fopen ( filename.c_str(), ";rb+" );
912
	FILE *id = _wfopen(filename.c_str(), L";rb+");
914
	if ( id )
913
	if ( id )
915
	{
914
	{
916
		fclose ( id );
915
		fclose(id);
917
		printf ( ";* File already exists, unable to create\n" );
916
		wprintf(L";* File already exists, unable to create\n");
918
		return;
917
		return;
919
	}
918
	}
920
 
919
 
921
	id = fopen ( filename.c_str(), ";wb" );
920
	id = _wfopen(filename.c_str(), L";wb");
922
	if ( !id )
921
	if ( !id )
923
	{
922
	{
924
		printf ( ";* Unable to open file for writing\n" );
923
		wprintf(L";* Unable to open file for writing\n");
925
		return;
924
		return;
926
	}
925
	}
927
	fclose ( id );
926
	fclose(id);
928
	remove ( filename.c_str() );
927
	_wremove(filename.c_str());
929
 
928
 
930
	CSpkFile spkfile;
929
	CSpkFile spkfile;
931
 
930
 
932
	printf ( "Enter Script Name: " );
931
	wprintf(L"Enter Script Name: ");
933
	spkfile.setName(GetInput().toString());
932
	spkfile.setName(GetInput());
934
 
-
 
935
	printf ( "Enter Script Author: " );
-
 
936
	spkfile.setAuthor(GetInput().toString());
-
 
937
 
933
 
938
	printf ( "Enter Script Version: " );
934
	wprintf(L"Enter Script Author: ");
939
	spkfile.setVersion(GetInput().toString());
935
	spkfile.setAuthor(GetInput());
940
 
936
 
-
 
937
	wprintf(L"Enter Script Version: ");
-
 
938
	spkfile.setVersion(GetInput());
-
 
939
 
941
	printf ( "Enter Script Description: " );
940
	wprintf(L"Enter Script Description: ");
942
	spkfile.setDescription(GetInput().toString());
941
	spkfile.setDescription(GetInput());
943
 
942
 
944
	struct tm   *currDate;
943
	struct tm   *currDate;
945
	char    dateString[100];
944
	char    dateString[100];
946
	time_t now = time(NULL);
945
	time_t now = time(NULL);
947
 
946
 
948
	currDate = localtime( &now );
947
	currDate = localtime( &now );
949
	strftime(dateString, sizeof dateString, "%d %m %Y", currDate);
948
	strftime(dateString, sizeof dateString, "%d %m %Y", currDate);
950
	spkfile.setCreationDate(Utils::WString::FromString(dateString));
949
	spkfile.setCreationDate(Utils::WString::FromString(dateString));
951
 
950
 
952
	spkfile.writeFile(filename.ToString(), NULL);
951
	spkfile.writeFile(filename, NULL);
953
	printf ( "SPK file has been written to disk: %s\n", filename.c_str() );
952
	wprintf(L"SPK file has been written to disk: %s\n", filename.c_str() );
954
}
953
}
955
 
954
 
956
void ExtractFiles (const Utils::String &sfile, const Utils::String &dir, int game )
955
void ExtractFiles (const Utils::WString &sfile, const Utils::WString &dir, int game )
957
{
956
{
958
	// First checks if the file exists by opening it
957
	// First checks if the file exists by opening it
959
	FILE *id = fopen ( sfile.c_str(), ";rb+" );
958
	FILE *id = _wfopen(sfile.c_str(), L";rb+");
960
	if ( !id )
959
	if ( !id )
961
	{
960
	{
962
		printf ( "Error: File, %s, doesn't exist\n", sfile.c_str() );
961
		wprintf(L"Error: File, %s, doesn't exist\n", sfile.c_str() );
963
		return;
962
		return;
964
	}
963
	}
965
	fclose ( id );
964
	fclose ( id );
966
 
965
 
967
	CPackages packages;
966
	CPackages packages;
Line 979... Line 978...
979
		else if ( check == SPKFILE_SINGLESHIP )
978
		else if ( check == SPKFILE_SINGLESHIP )
980
			pBaseFile = (CBaseFile *)new CXspFile();
979
			pBaseFile = (CBaseFile *)new CXspFile();
981
		else
980
		else
982
			pBaseFile = new CBaseFile();
981
			pBaseFile = new CBaseFile();
983
 
982
 
984
		printf ( ";Opening File, %s... ", sfile.c_str() );
983
		wprintf(L";Opening File, %s... ", sfile.c_str());
985
		// reads the file into memory
984
		// reads the file into memory
986
		// the SPKREAD_NODATA flag causes it to just read the settings, and skips the file data
985
		// the SPKREAD_NODATA flag causes it to just read the settings, and skips the file data
987
		if ( !pBaseFile->readFile(sfile, SPKREAD_NODATA))
986
		if ( !pBaseFile->readFile(sfile, SPKREAD_NODATA))
988
		{
987
		{
989
			printf ( "(Error)\nUnable to open the file, %s\n", sfile.c_str() );
988
			wprintf(L"(Error)\nUnable to open the file, %s\n", sfile.c_str() );
990
			return;
989
			return;
991
		}
990
		}
992
		printf ( "(Done)\n" );
991
		wprintf(L"(Done)\n");
993
 
992
 
994
		if(game == 0)
993
		if(game == 0)
995
			printf("Extracting all files from archive...\n\n");
994
			wprintf(L"Extracting all files from archive...\n\n");
996
		else
995
		else
997
			wprintf(L"Extracting %s files from archive...\n\n", packages.GetGameExe()->gameNameFromType(game - 1).c_str());
996
			wprintf(L"Extracting %s files from archive...\n\n", packages.GetGameExe()->gameNameFromType(game - 1).c_str());
998
 
997
 
999
		CFileProgress info(&packages, pBaseFile, "Extracting");
998
		CFileProgress info(&packages, pBaseFile, "Extracting");
1000
		if (packages.extractAll(pBaseFile, dir, game, true, &info) )
999
		if (packages.extractAll(pBaseFile, dir, game, true, &info) )
1001
			printf ( ";\n(Done)\nFiles have been extracted successfully\n" );
1000
			wprintf(L";\n(Done)\nFiles have been extracted successfully\n");
1002
		else
1001
		else
1003
			printf ( ";\n(Error)\nThere was a problem extracting the files\n" );
1002
			wprintf(L";\n(Error)\nThere was a problem extracting the files\n");
1004
	}
1003
	}
1005
	else
1004
	else
1006
		printf("Invalid package file, %s\n", sfile.c_str());
1005
		wprintf(L"Invalid package file, %s\n", sfile.c_str());
1007
}
1006
}
1008
 
1007
 
1009
 
1008
 
1010
/*
1009
/*
1011
	Func:	AppendMultiFile
1010
	Func:	AppendMultiFile
Line 1013... Line 1012...
1013
			String addfile	- The spk file to append
1012
			String addfile	- The spk file to append
1014
	Desc:	Appends a spk file into a Multi-Spk Archive
1013
	Desc:	Appends a spk file into a Multi-Spk Archive
1015
			If toFile is a single spk file, it will be converted to a Multi-Spk File
1014
			If toFile is a single spk file, it will be converted to a Multi-Spk File
1016
			if addfile is a Multi-Spk file, all files from it will be appended
1015
			if addfile is a Multi-Spk file, all files from it will be appended
1017
*/
1016
*/
1018
void AppendMultiFile ( CyString toFile, CyString addfile )
1017
void AppendMultiFile(const Utils::WString &toFile, const Utils::WString &addfile)
1019
{
1018
{
1020
	// create destination object
1019
	// create destination object
1021
	CMultiSpkFile spkfile;
1020
	CMultiSpkFile spkfile;
1022
 
1021
 
1023
	// checks the destination
1022
	// checks the destination
1024
	int checkto = CSpkFile::CheckFile(toFile.ToString());
1023
	int checkto = CSpkFile::CheckFile(toFile);
1025
 
1024
 
1026
	// if the destination is a single file, then convert it to a Multi-Spk package
1025
	// if the destination is a single file, then convert it to a Multi-Spk package
1027
	if ( checkto == SPKFILE_SINGLE )
1026
	if ( checkto == SPKFILE_SINGLE )
1028
	{
1027
	{
1029
		// adds the single file to the Multi-Spk object
1028
		// adds the single file to the Multi-Spk object
1030
		// Add file also reads it into memory
1029
		// Add file also reads it into memory
1031
		if ( !spkfile.addFile(toFile.ToString()))
1030
		if ( !spkfile.addFile(toFile))
1032
		{
1031
		{
1033
			printf ( ";Error: Unable to create Multi-Spk file\n" );
1032
			wprintf(L";Error: Unable to create Multi-Spk file\n");
1034
			return;
1033
			return;
1035
		}
1034
		}
1036
	}
1035
	}
1037
	else
1036
	else
1038
	{
1037
	{
1039
		// if its already a multispk file, then simply open it and read it to memory
1038
		// if its already a multispk file, then simply open it and read it to memory
1040
		if ( !spkfile.readFile(toFile.ToString()))
1039
		if ( !spkfile.readFile(toFile))
1041
		{
1040
		{
1042
			printf ( "Error: Unable to open Multi-Spk file, %s\n", toFile.c_str() );
1041
			wprintf(L"Error: Unable to open Multi-Spk file, %s\n", toFile.c_str());
1043
			return;
1042
			return;
1044
		}
1043
		}
1045
	}
1044
	}
1046
 
1045
 
1047
	// now add the file into the Multi-Spk Object
1046
	// now add the file into the Multi-Spk Object
1048
	// the AddFile function will handle both single and Multi-Spk files
1047
	// the AddFile function will handle both single and Multi-Spk files
1049
	// So you dont need to test what the appending file is
1048
	// So you dont need to test what the appending file is
1050
	if ( spkfile.addFile(addfile.ToString()))
1049
	if ( spkfile.addFile(addfile))
1051
	{
1050
	{
1052
 
1051
 
1053
		// if it added correctly, then simply write the new Multi-Spk Object to disk
1052
		// if it added correctly, then simply write the new Multi-Spk Object to disk
1054
		printf ( "File, %s, has been added to Multi-Spk Package\n", addfile.c_str() );
1053
		wprintf(L"File, %s, has been added to Multi-Spk Package\n", addfile.c_str());
1055
		printf ( "Saving Multi-Spk File: %s... ", toFile.c_str() );
1054
		wprintf(L"Saving Multi-Spk File: %s... ", toFile.c_str());
1056
		if ( spkfile.writeFile(toFile.ToString()))
1055
		if ( spkfile.writeFile(toFile))
1057
			printf ( "(Done)\n" );
1056
			wprintf(L"(Done)\n");
1058
		else
1057
		else
1059
			printf ( "(Error)\n" );
1058
			wprintf(L"(Error)\n");
1060
	}
1059
	}
1061
	else
1060
	else
1062
		printf ( "Error: Unable to add files, %s, to Multi-Spk Package\n", addfile.c_str() );
1061
		wprintf(L"Error: Unable to add files, %s, to Multi-Spk Package\n", addfile.c_str());
1063
}
1062
}
1064
 
1063
 
1065
/*
1064
/*
1066
	Func:	ExtractFile
1065
	Func:	ExtractFile
1067
	Args:	String sfile	- the spk file to read from
1066
	Args:	String sfile	- the spk file to read from
1068
			String type		- the type of the file to find
1067
			String type		- the type of the file to find
1069
			String addfile	- The filename to extract
1068
			String addfile	- The filename to extract
1070
			String dir		- The directory to extract to
1069
			String dir		- The directory to extract to
1071
	Desc:	Finds and extracts a file from a Spk Package
1070
	Desc:	Finds and extracts a file from a Spk Package
1072
*/
1071
*/
1073
void ExtractFile (const Utils::String &sfile, const Utils::String &type, const Utils::String &addfile, const Utils::String &dir)
1072
void ExtractFile (const Utils::WString &sfile, const Utils::WString &type, const Utils::WString &addfile, const Utils::WString &dir)
1074
{
1073
{
1075
	// First checks if the file exists by opening it
1074
	// First checks if the file exists by opening it
1076
	FILE *id = fopen ( sfile.c_str(), ";rb+" );
1075
	FILE *id = _wfopen(sfile.c_str(), L";rb+");
1077
	if ( !id )
1076
	if ( !id )
1078
	{
1077
	{
1079
		printf ( "Error: File, %s, doesn't exist\n", sfile.c_str() );
1078
		wprintf(L"Error: File, %s, doesn't exist\n", sfile.c_str());
1080
		return;
1079
		return;
1081
	}
1080
	}
1082
	fclose ( id );
1081
	fclose ( id );
1083
 
1082
 
1084
	// now check the type of file it is, using the static function CheckFile(filename).
1083
	// now check the type of file it is, using the static function CheckFile(filename).
Line 1097... Line 1096...
1097
		// converts the string type into its filetype flag
1096
		// converts the string type into its filetype flag
1098
		FileType t = GetFileTypeFromString(type);
1097
		FileType t = GetFileTypeFromString(type);
1099
		// incorrect text type, display the error
1098
		// incorrect text type, display the error
1100
		if (t == FileType::FILETYPE_UNKNOWN)
1099
		if (t == FileType::FILETYPE_UNKNOWN)
1101
		{
1100
		{
1102
			printf ( "The file type \&quot;%s\" is invalid\n", type.c_str() );
1101
			wprintf(L"The file type \&quot;%s\" is invalid\n", type.c_str());
1103
			return;
1102
			return;
1104
		}
1103
		}
1105
 
1104
 
1106
		// creates the spkfile object
1105
		// creates the spkfile object
1107
		CBaseFile *pBaseFile = 0;
1106
		CBaseFile *pBaseFile = 0;
Line 1110... Line 1109...
1110
		else if ( check == SPKFILE_SINGLESHIP )
1109
		else if ( check == SPKFILE_SINGLESHIP )
1111
			pBaseFile = (CBaseFile *)new CXspFile();
1110
			pBaseFile = (CBaseFile *)new CXspFile();
1112
		else
1111
		else
1113
			pBaseFile = new CBaseFile();
1112
			pBaseFile = new CBaseFile();
1114
 
1113
 
1115
		printf ( ";Opening File, %s... ", sfile.c_str() );
1114
		wprintf(L";Opening File, %s... ", sfile.c_str());
1116
		// reads the file into memory
1115
		// reads the file into memory
1117
		// the SPKREAD_NODATA flag causes it to just read the settings, and skips the file data
1116
		// the SPKREAD_NODATA flag causes it to just read the settings, and skips the file data
1118
		if ( !pBaseFile->readFile(sfile, SPKREAD_NODATA))
1117
		if ( !pBaseFile->readFile(sfile, SPKREAD_NODATA))
1119
		{
1118
		{
1120
			printf ( "(Error)\nUnable to open the file, %s\n", sfile.c_str() );
1119
			wprintf(L"(Error)\nUnable to open the file, %s\n", sfile.c_str());
1121
			return;
1120
			return;
1122
		}
1121
		}
1123
 
1122
 
1124
		// No read all the file data into memory
1123
		// No read all the file data into memory
1125
		// This can be done all together in the ReadFile function
1124
		// This can be done all together in the ReadFile function
1126
		// Doing it seperatly allows you to save time if an error occurs, so you dont have to wait for it to read the whole thing
1125
		// Doing it seperatly allows you to save time if an error occurs, so you dont have to wait for it to read the whole thing
1127
		pBaseFile->ReadAllFilesToMemory ();
1126
		pBaseFile->ReadAllFilesToMemory ();
1128
 
1127
 
1129
		printf ( "(Done)\n" );
1128
		wprintf(L"(Done)\n");
1130
 
1129
 
1131
		// uses the FindFile function to find the selected file in the archive
1130
		// uses the FindFile function to find the selected file in the archive
1132
		// requires the filename, type and custom directory (only for Extra File Type)
1131
		// requires the filename, type and custom directory (only for Extra File Type)
1133
		C_File *f = pBaseFile->findFile(addfile, t);
1132
		C_File *f = pBaseFile->findFile(addfile, t);
1134
		if ( !f )
1133
		if ( !f )
1135
		{
1134
		{
1136
			printf ( "Unable to find the file \"%s\" in the package\n", addfile.c_str() );
1135
			wprintf(L"Unable to find the file \"%s\" in the package\n", addfile.c_str());
1137
			return;
1136
			return;
1138
		}
1137
		}
1139
 
1138
 
1140
		// creates the directory so it can be extracted
1139
		// creates the directory so it can be extracted
1141
		CDirIO Dir(dir);
1140
		CDirIO Dir(dir);
1142
		if ( !Dir.create(f->getDirectory(pBaseFile)) )
1141
		if ( !Dir.create(f->getDirectory(pBaseFile)) )
1143
		{
1142
		{
1144
			printf ( "Unable to create the directory \"%s\" to extract into\n", dir.c_str() );
1143
			wprintf(L"Unable to create the directory \"%s\" to extract into\n", dir.c_str());
1145
			return;
1144
			return;
1146
		}
1145
		}
1147
 
1146
 
1148
		// sets up the progress pointer
1147
		// sets up the progress pointer
1149
		// if it uses 7zip, the progress will be displayed in the command prompt
1148
		// if it uses 7zip, the progress will be displayed in the command prompt
1150
		MyProgress progress(0);
1149
		MyProgress progress(0);
1151
		printf ( ";Extracting the file from package\n\t>" );
1150
		wprintf(L";Extracting the file from package\n\t>");
1152
 
1151
 
1153
		// Extracts the file to the specified directory
1152
		// Extracts the file to the specified directory
1154
		if ( !pBaseFile->extractFile(f, dir, true, &progress))
1153
		if ( !pBaseFile->extractFile(f, dir, true, &progress))
1155
			printf ( ";&lt; (Error)\nUnable to extract the file\n" );
1154
			wprintf(L";&lt; (Error)\nUnable to extract the file\n");
1156
		else
1155
		else
1157
		{
1156
		{
1158
			progress.PrintDone ();
1157
			progress.PrintDone ();
1159
			printf ( ";&lt; (Done)\nFile has been extracted successfully\n" );
1158
			wprintf(L";&lt; (Done)\nFile has been extracted successfully\n");
1160
		}
1159
		}
1161
	}
1160
	}
1162
 
1161
 
1163
	// the file is a Multi-Spk File, extracts a single spk file from the archive
1162
	// the file is a Multi-Spk File, extracts a single spk file from the archive
1164
	else if ( check == SPKFILE_MULTI )
1163
	else if ( check == SPKFILE_MULTI )
1165
	{
1164
	{
1166
		// creates MultiSpkFile object
1165
		// creates MultiSpkFile object
1167
		CMultiSpkFile spkfile;
1166
		CMultiSpkFile spkfile;
1168
		printf ( "Opening Multi-SPK file, %s...", sfile.c_str() );
1167
		wprintf(L"Opening Multi-SPK file, %s...", sfile.c_str());
1169
 
1168
 
1170
		// reads the MultiSpkFile into memory
1169
		// reads the MultiSpkFile into memory
1171
		if ( !spkfile.readFile(sfile))
1170
		if ( !spkfile.readFile(sfile))
1172
		{
1171
		{
1173
			printf ( "(Error)\nUnable to open the Multi-SPK file, %s\n", sfile.c_str() );
1172
			wprintf(L"(Error)\nUnable to open the Multi-SPK file, %s\n", sfile.c_str());
1174
			return;
1173
			return;
1175
		}
1174
		}
1176
		printf ( "(Done)\n" );
1175
		wprintf(L"(Done)\n");
1177
 
1176
 
1178
		// searchs the archive for a matching file
1177
		// searchs the archive for a matching file
1179
		const SMultiSpkFile *ms = spkfile.findFile(type);
1178
		const SMultiSpkFile *ms = spkfile.findFile(type);
1180
		if ( !ms )
1179
		if ( !ms )
1181
		{
1180
		{
1182
			printf ( "Unable to find the file \"%s\" in the package\n", type.c_str() );
1181
			wprintf(L"Unable to find the file \"%s\" in the package\n", type.c_str());
1183
			return;
1182
			return;
1184
		}
1183
		}
1185
 
1184
 
1186
		// extracts the file from the archive, to the given directory
1185
		// extracts the file from the archive, to the given directory
1187
		wprintf(L"Extracting SPK file, %s, from package... ", ms->sName.c_str() );
1186
		wprintf(L"Extracting SPK file, %s, from package... ", ms->sName.c_str());
1188
		if (spkfile.extractFile(ms, addfile))
1187
		if (spkfile.extractFile(ms, addfile))
1189
			printf ( "(Done)\n" );
1188
			wprintf(L"(Done)\n");
1190
		else
1189
		else
1191
			printf ( "(Error)\n" );
1190
			wprintf(L"(Error)\n");
1192
	}
1191
	}
1193
	else
1192
	else
1194
		printf ( ";Error: Invalid file format, unable to open\n" );
1193
		wprintf(L";Error: Invalid file format, unable to open\n");
1195
}
1194
}
1196
 
1195
 
1197
/*
1196
/*
1198
	Func:	SplitMulti
1197
	Func:	SplitMulti
1199
	Args:	String filename - the filename of the multispk file to open
1198
	Args:	String filename - the filename of the multispk file to open
1200
			String dest		- The destination directory to extract the files to
1199
			String dest		- The destination directory to extract the files to
1201
	Desc:	Splits a multi-spk file into its seperate spk files
1200
	Desc:	Splits a multi-spk file into its seperate spk files
1202
*/
1201
*/
1203
void SplitMulti ( CyString filename, CyString dest )
1202
void SplitMulti(const Utils::WString &filename, const Utils::WString &dest)
1204
{
1203
{
1205
	// Check the file type, Must return SPKFILE_MULTI, otherwise its not a Multi-Spk Packages
1204
	// Check the file type, Must return SPKFILE_MULTI, otherwise its not a Multi-Spk Packages
1206
	if ( CSpkFile::CheckFile(filename.ToString()) != SPKFILE_MULTI )
1205
	if ( CSpkFile::CheckFile(filename) != SPKFILE_MULTI )
1207
	{
1206
	{
1208
		printf ( "Error: The file is not a Multi-Spk packages\n" );
1207
		wprintf(L"Error: The file is not a Multi-Spk packages\n");
1209
		return;
1208
		return;
1210
	}
1209
	}
1211
 
1210
 
1212
	printf ( "Spliting Multi-SPK File to, %s... ", dest.c_str() );
1211
	wprintf(L"Spliting Multi-SPK File to, %s... ", dest.c_str());
1213
 
1212
 
1214
	// create the MultiSpkFile object
1213
	// create the MultiSpkFile object
1215
	CMultiSpkFile spkfile;
1214
	CMultiSpkFile spkfile;
1216
 
1215
 
1217
	// Splits the files to the destination
1216
	// Splits the files to the destination
1218
	if ( !spkfile.splitMulti(filename.ToString(), dest.ToString()))
1217
	if ( !spkfile.splitMulti(filename, dest))
1219
	{
1218
	{
1220
		printf ( "(Error)\nUnable to split Multi-SPK package, %s\n", filename.c_str() );
1219
		wprintf(L"(Error)\nUnable to split Multi-SPK package, %s\n", filename.c_str());
1221
		return;
1220
		return;
1222
	}
1221
	}
1223
 
1222
 
1224
	printf ( "(Done)\n" );
1223
	wprintf(L"(Done)\n");
1225
}
1224
}
1226
 
1225
 
1227
Utils::WString GetAsk(const Utils::WString &command)
1226
Utils::WString GetAsk(const Utils::WString &command)
1228
{
1227
{
1229
	wprintf(L"(ASK) Enter the value for, %s: ", command.c_str());
1228
	wprintf(L"(ASK) Enter the value for, %s: ", command.c_str());
Line 1236... Line 1235...
1236
	CDirIO Dir(currentDir);
1235
	CDirIO Dir(currentDir);
1237
 
1236
 
1238
	Utils::WStringList list;
1237
	Utils::WStringList list;
1239
	for (int i = 2; i < argc; ++i)
1238
	for (int i = 2; i < argc; ++i)
1240
	{
1239
	{
1241
		Utils::String file(argv[i]);
1240
		Utils::WString file(argv[i]);
1242
		if (CFileIO::Exists(file))
1241
		if (CFileIO::Exists(file))
1243
			list.pushBack(file, L"file");
1242
			list.pushBack(file, L"file");
1244
		else if (CFileIO::Exists(Dir.file(file)))
1243
		else if (CFileIO::Exists(Dir.file(file)))
1245
			list.pushBack(Dir.file(file), L"file");
1244
			list.pushBack(Dir.file(file), L"file");
1246
		else if (CDirIO::Exists(file))
1245
		else if (CDirIO::Exists(file))
Line 1250... Line 1249...
1250
		else
1249
		else
1251
			list.pushBack(file, L"pattern");
1250
			list.pushBack(file, L"pattern");
1252
	}
1251
	}
1253
 
1252
 
1254
	if (list.empty())
1253
	if (list.empty())
1255
		printf("unable to find any packages");
1254
		wprintf(L"unable to find any packages");
1256
	else
1255
	else
1257
	{
1256
	{
1258
		Utils::WStringList fileList;
1257
		Utils::WStringList fileList;
1259
		for (auto itr = list.begin(); itr != list.end(); itr++)
1258
		for (auto itr = list.begin(); itr != list.end(); itr++)
1260
		{
1259
		{
1261
			Utils::WString file = (*itr)->str;
1260
			Utils::WString file = (*itr)->str;
1262
			Utils::WString data = (*itr)->data;
1261
			Utils::WString data = (*itr)->data;
Line 1265... Line 1264...
1265
			else if (data == L"dir")
1264
			else if (data == L"dir")
1266
			{
1265
			{
1267
				CDirIO dir(file);
1266
				CDirIO dir(file);
1268
				Utils::WStringList d;
1267
				Utils::WStringList d;
1269
				if (dir.dirList(d))
1268
				if (dir.dirList(d))
1270
				{
1269
				{
1271
					for (auto itr2 = d.begin(); itr2 != d.end(); itr2++)
1270
					for (auto itr2 = d.begin(); itr2 != d.end(); itr2++)
1272
					{
1271
					{
1273
						Utils::WString ext = CFileIO((*itr2)->str).extension().lower();
1272
						Utils::WString ext = CFileIO((*itr2)->str).extension().lower();
1274
						if(ext == L"xsp" || ext == L"spk")
1273
						if(ext == L"xsp" || ext == L"spk")
1275
							fileList.pushBack(dir.file((*itr2)->str));
1274
							fileList.pushBack(dir.file((*itr2)->str));
1276
					}
1275
					}
1277
				}
1276
				}
1278
			}
1277
			}
Line 1296... Line 1295...
1296
				}
1295
				}
1297
			}
1296
			}
1298
		}
1297
		}
1299
 
1298
 
1300
		if (fileList.empty())
1299
		if (fileList.empty())
1301
			printf("unable to find any packages");
1300
			wprintf(L"unable to find any packages");
1302
		else
1301
		else
1303
		{
1302
		{
1304
			CPackages packages;
1303
			CPackages packages;
1305
 
1304
 
1306
			Utils::WStringList filedata;
1305
			Utils::WStringList filedata;
1307
			for (auto itr = fileList.begin(); itr != fileList.end(); itr++)
1306
			for (auto itr = fileList.begin(); itr != fileList.end(); itr++)
1308
			{
1307
			{
1309
				wprintf(L"Reading file: %s\n", (*itr)->str.c_str());
1308
				wprintf(L"Reading file: %s\n", (*itr)->str.c_str());
1310
 
1309
 
Line 1324... Line 1323...
1324
				filedata.pushBack(CPackages::FormatAvailablePackageData(p));
1323
				filedata.pushBack(CPackages::FormatAvailablePackageData(p));
1325
				delete p;
1324
				delete p;
1326
			}
1325
			}
1327
 
1326
 
1328
			if (filedata.empty())
1327
			if (filedata.empty())
1329
				printf("unable to find any packages");
1328
				wprintf(L"unable to find any packages");
1330
			else				
1329
			else				
1331
			{
1330
			{
1332
				Utils::WString dest = Dir.file(L"xpackagedata.dat");
1331
				Utils::WString dest = Dir.file(L"xpackagedata.dat");
1333
				if (CFileIO(dest).writeFile(&filedata))
1332
				if (CFileIO(dest).writeFile(&filedata))
1334
					printf("web update file, xpackagedata.dat, generated");
1333
					wprintf(L"web update file, xpackagedata.dat, generated");
1335
				else
1334
				else
1336
					printf("unable to write update file");
1335
					wprintf(L"unable to write update file");
1337
			}
1336
			}
1338
		}
1337
		}
1339
	}
1338
	}
1340
}
1339
}
1341
 
1340
 
1342
void GenerateUpdateFile(const Utils::WString &spkfile)
1341
void GenerateUpdateFile(const Utils::WString &spkfile)
1343
{
1342
{
1344
	if (!CFileIO::Exists(spkfile))
1343
	if (!CFileIO::Exists(spkfile))
1345
	{
1344
	{
1346
		wprintf(L"Error: The package file, %s, does not exist", spkfile.c_str());
1345
		wprintf(L"Error: The package file, %s, does not exist", spkfile.c_str());
1347
		return;
1346
		return;
1348
	}
1347
	}
1349
 
1348
 
1350
	int check = CSpkFile::CheckFile(spkfile);
1349
	int check = CSpkFile::CheckFile(spkfile);
1351
	if ( check == SPKFILE_MULTI )
1350
	if ( check == SPKFILE_MULTI )
1352
	{
-
 
1353
		printf("Error: Multi-Package files currently not supported\n");
-
 
1354
		return;
-
 
1355
	}
-
 
1356
	else if ( check == SPKFILE_OLD )
-
 
1357
	{
1351
	{
-
 
1352
		wprintf(L"Error: Multi-Package files currently not supported\n");
-
 
1353
		return;
-
 
1354
	}
-
 
1355
	else if ( check == SPKFILE_OLD )
-
 
1356
	{
1358
		printf("Error: unable to read old format spk file, try spkconvert first\n");
1357
		wprintf(L"Error: unable to read old format spk file, try spkconvert first\n");
1359
		return;
1358
		return;
1360
	}
1359
	}
1361
	else if ( check == SPKFILE_INVALID )
1360
	else if ( check == SPKFILE_INVALID )
1362
	{
1361
	{
1363
		wprintf(L"Error: %s doesn't appear to be a valid package file\n", spkfile.c_str());
1362
		wprintf(L"Error: %s doesn't appear to be a valid package file\n", spkfile.c_str());
1364
		return;
1363
		return;
1365
	}
1364
	}
1366
 
1365
 
1367
	CPackages p;
1366
	CPackages p;
1368
	int error;
1367
	int error;
1369
	CBaseFile *package = p.openPackage(spkfile.toString(), &error, 0, SPKREAD_NODATA);
1368
	CBaseFile *package = p.openPackage(spkfile, &error, 0, SPKREAD_NODATA);
1370
	if ( !package )
1369
	if ( !package )
1371
	{
1370
	{
1372
		wprintf(L"Error: unable to open package file, %s, Error=%d\n", spkfile.c_str(), error);
1371
		wprintf(L"Error: unable to open package file, %s, Error=%d\n", spkfile.c_str(), error);
1373
		return;
1372
		return;
1374
	}
1373
	}
Line 1381... Line 1380...
1381
 
1380
 
1382
	delete package;
1381
	delete package;
1383
 
1382
 
1384
}
1383
}
1385
 
1384
 
1386
void GeneratePackagerScript(const Utils::String &spkfile, CyString toFile, int game)
1385
void GeneratePackagerScript(const Utils::WString &spkfile, Utils::WString toFile, int game)
1387
{
1386
{
1388
	if (!CFileIO::Exists(spkfile))
1387
	if (!CFileIO::Exists(spkfile))
1389
	{
1388
	{
1390
		printf("Error: The package file, %s, does not exist", spkfile.c_str());
1389
		wprintf(L"Error: The package file, %s, does not exist", spkfile.c_str());
1391
		return;
1390
		return;
1392
	}
1391
	}
1393
 
1392
 
1394
	int check = CSpkFile::CheckFile(spkfile);
1393
	int check = CSpkFile::CheckFile(spkfile);
1395
	if ( check == SPKFILE_MULTI )
1394
	if ( check == SPKFILE_MULTI )
1396
	{
1395
	{
1397
		printf("Error: Cant generate a script from a multi-spk file\n");
1396
		wprintf(L"Error: Cant generate a script from a multi-spk file\n");
1398
		return;
1397
		return;
1399
	}
1398
	}
1400
	else if ( check == SPKFILE_OLD )
1399
	else if ( check == SPKFILE_OLD )
1401
	{
1400
	{
1402
		printf("Error: unable to read old format spk file, try spkconvert first\n");
1401
		wprintf(L"Error: unable to read old format spk file, try spkconvert first\n");
1403
		return;
1402
		return;
1404
	}
1403
	}
1405
	else if ( check == SPKFILE_INVALID )
1404
	else if ( check == SPKFILE_INVALID )
1406
	{
1405
	{
1407
		printf("Error: %s doesn't appear to be a spk file\n", spkfile.c_str());
1406
		wprintf(L"Error: %s doesn't appear to be a spk file\n", spkfile.c_str());
1408
		return;
1407
		return;
1409
	}
1408
	}
1410
 
1409
 
1411
	CPackages p;
1410
	CPackages p;
1412
	p.startup(L".", L".", L".");
1411
	p.startup(L".", L".", L".");
1413
	int error;
1412
	int error;
1414
	CBaseFile *package = p.openPackage(spkfile, &error, 0, SPKREAD_NODATA);
1413
	CBaseFile *package = p.openPackage(spkfile, &error, 0, SPKREAD_NODATA);
1415
	if ( !package )
1414
	if ( !package )
1416
	{
1415
	{
1417
		printf("Error: unable to open package files, %s, Error=%d\n", spkfile.c_str(), error);
1416
		wprintf(L"Error: unable to open package files, %s, Error=%d\n", spkfile.c_str(), error);
1418
		return;
1417
		return;
1419
	}
1418
	}
1420
 
1419
 
1421
	Utils::WStringList list;
1420
	Utils::WStringList list;
1422
	if ( !p.generatePackagerScript(package, true, &list, game) )
1421
	if ( !p.generatePackagerScript(package, true, &list, game) )
1423
	{
1422
	{
1424
		printf("Error: Unable to generate packager script\n");
1423
		wprintf(L"Error: Unable to generate packager script\n");
1425
		return;
1424
		return;
1426
	}
1425
	}
1427
 
1426
 
1428
	if ( toFile.Empty() )
1427
	if ( toFile.empty() )
1429
		toFile = CFileIO(spkfile).GetDirIO().file(package->name() + L"_" + package->author() + L".sps").toString();
1428
		toFile = CFileIO(spkfile).GetDirIO().file(package->name() + L"_" + package->author() + L".sps");
1430
 
1429
 
1431
	// save package file
1430
	// save package file
1432
	if ( CFileIO(toFile.ToString()).writeFile(&list) )
1431
	if ( CFileIO(toFile).writeFile(&list) )
1433
		printf("Packager script, %s, has been geenrated\n", toFile.c_str());
1432
		wprintf(L"Packager script, %s, has been geenrated\n", toFile.c_str());
1434
	else
1433
	else
1435
		printf("Error: unable to write packager script, %s\n", toFile.c_str());
1434
		wprintf(L"Error: unable to write packager script, %s\n", toFile.c_str());
1436
 
1435
 
1437
	delete package;
1436
	delete package;
1438
}
1437
}
1439
 
1438
 
1440
/*
1439
/*
Line 1622... Line 1621...
1622
	{
1621
	{
1623
		if ( argc < 4 )
1622
		if ( argc < 4 )
1624
			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.c_str(), cmd.c_str(), fileTypes.c_str() );
1625
		else
1624
		else
1626
		{
1625
		{
1627
			CyString arg4;
1626
			Utils::WString arg4;
1628
			if ( argc > 4 )
1627
			if ( argc > 4 )
1629
				arg4 = argv[4];
1628
				arg4 = argv[4];
1630
			AppendFile ( argv[2], argv[3], arg4 );
1629
			AppendFile ( argv[2], argv[3], arg4 );
1631
		}
1630
		}
1632
	}
1631
	}
Line 1639... Line 1638...
1639
			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.c_str(), cmd.c_str(), fileTypes.c_str() );
1640
			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.c_str(), cmd.c_str() );
1641
		}
1640
		}
1642
		else
1641
		else
1643
		{
1642
		{
1644
			CyString arg4;
1643
			Utils::WString arg4;
1645
			if ( argc > 4 )
1644
			if ( argc > 4 )
1646
				arg4 = argv[4];
1645
				arg4 = argv[4];
1647
			RemoveFile ( argv[2], argv[3], arg4 );
1646
			RemoveFile ( argv[2], argv[3], arg4 );
1648
		}
1647
		}
1649
	}
1648
	}
Line 1653... Line 1652...
1653
	{
1652
	{
1654
		if ( argc < 4 )
1653
		if ( argc < 4 )
1655
			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.c_str() );
1656
		else
1655
		else
1657
		{
1656
		{
1658
			Utils::String arg4;
1657
			Utils::WString arg4;
1659
			if ( argc > 4 )
1658
			if ( argc > 4 )
1660
				arg4 = argv[3];
1659
				arg4 = argv[3];
1661
			ExtractFile(argv[2], argv[3], arg4, Utils::String::Null());
1660
			ExtractFile(argv[2], argv[3], arg4, Utils::WString::Null());
1662
		}
1661
		}
1663
	}
1662
	}
1664
	else if ( command == L"-x" || command == L"--extract")
1663
	else if ( command == L"-x" || command == L"--extract")
1665
	{
1664
	{
1666
		if ( argc < 4 )
1665
		if ( argc < 4 )
Line 1668... Line 1667...
1668
			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.c_str(), fileTypes.c_str() );
1669
			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.c_str() );
1670
		}
1669
		}
1671
		else
1670
		else
1672
		{
1671
		{
1673
			Utils::String arg5, arg4;
1672
			Utils::WString arg5, arg4;
1674
			if ( argc > 5 )
1673
			if ( argc > 5 )
1675
				arg5 = argv[5];
1674
				arg5 = argv[5];
1676
			if ( argc > 4 )
1675
			if ( argc > 4 )
1677
				arg4 = argv[4];
1676
				arg4 = argv[4];
1678
			ExtractFile(argv[2], argv[3], arg4, arg5);
1677
			ExtractFile(argv[2], argv[3], arg4, arg5);
Line 1684... Line 1683...
1684
	{
1683
	{
1685
		if ( argc < 3 )
1684
		if ( argc < 3 )
1686
			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.c_str() );
1687
		else
1686
		else
1688
		{
1687
		{
1689
			Utils::String arg4;
1688
			Utils::WString arg4;
1690
			if ( argc > 4 )
1689
			if ( argc > 4 )
1691
				arg4 = argv[4];
1690
				arg4 = argv[4];
1692
			ExtractFiles(argv[2], arg4, CBaseFile::GetGameFromString(argv[3]));
1691
			ExtractFiles(argv[2], arg4, CBaseFile::GetGameFromString(argv[3]));
1693
		}
1692
		}
1694
	}
1693
	}
Line 1716... Line 1715...
1716
	{
1715
	{
1717
		if ( argc < 3 )
1716
		if ( argc < 3 )
1718
			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.c_str() );
1719
		else
1718
		else
1720
		{
1719
		{
1721
			CyString arg3;
1720
			Utils::WString arg3;
1722
			if ( argc > 3 )
1721
			if ( argc > 3 )
1723
				arg3 = argv[3];
1722
				arg3 = argv[3];
1724
			SplitMulti ( argv[2], arg3 );
1723
			SplitMulti ( argv[2], arg3 );
1725
		}
1724
		}
1726
	}
1725
	}
Line 1735... Line 1734...
1735
	else if ( command == L"--setrating" )
1734
	else if ( command == L"--setrating" )
1736
	{
1735
	{
1737
		if ( argc < 6 )
1736
		if ( argc < 6 )
1738
			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.c_str() );
1739
		else
1738
		else
1740
			SetRating(argv[2], CyString(argv[3]).ToInt(), CyString(argv[4]).ToInt(), CyString(argv[5]).ToInt());
1739
			SetRating(argv[2], Utils::WString(argv[3]).toInt(), Utils::WString(argv[4]).toInt(), Utils::WString(argv[5]).toInt());
1741
	}
1740
	}
1742
	else if ( command == L"--convertxsp" || command == L"--convertxspwizard" )
1741
	else if ( command == L"--convertxsp" || command == L"--convertxspwizard" )
1743
	{
1742
	{
1744
		if ( argc < 3 )
1743
		if ( argc < 3 )
1745
			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.c_str(), command.c_str() );
1746
		else
1745
		else
1747
		{
1746
		{
1748
			Utils::String arg3;
1747
			Utils::WString arg3;
1749
			if ( argc > 3 )
1748
			if ( argc > 3 )
1750
				arg3 = argv[3];
1749
				arg3 = argv[3];
1751
			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);
1752
		}
1751
		}
1753
	}
1752
	}
Line 1804... Line 1803...
1804
			GenerateUpdateList(argc, argv);
1803
			GenerateUpdateList(argc, argv);
1805
	}
1804
	}
1806
 
1805
 
1807
	// not a valid switch, display syntax
1806
	// not a valid switch, display syntax
1808
	else
1807
	else
1809
		PrintSyntax ( CyString(cmd.toString()) );
1808
		PrintSyntax(cmd);
1810
 
1809
 
1811
#ifdef _DEBUG
1810
#ifdef _DEBUG
1812
	char pause;
1811
	char pause;
1813
	scanf ( "%s", &pause );
1812
	scanf ( "%s", &pause );
1814
#endif
1813
#endif