Subversion Repositories spk

Rev

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

Rev 307 Rev 311
Line 40... Line 40...
40
		_package(package)
40
		_package(package)
41
	{
41
	{
42
 
42
 
43
	}
43
	}
44
 
44
 
-
 
45
	void UpdateDisplay(const Utils::WString& display) override
-
 
46
	{
-
 
47
		wprintf(L"%s\n", display.c_str());
-
 
48
	}
-
 
49
 
45
protected:
50
protected:
46
	void ProgressUpdated(const long cur, const long max)
51
	void ProgressUpdated(const long cur, const long max)
47
	{
52
	{
48
	}
53
	}
49
	void DoingFile(C_File *file)
54
	void DoingFile(C_File *file)
Line 1443... Line 1448...
1443
/*
1448
/*
1444
	Func:	LoadPackagerScript
1449
	Func:	LoadPackagerScript
1445
	Args:	String filename	-	The filename of the packager script to load
1450
	Args:	String filename	-	The filename of the packager script to load
1446
	Desc:	Loads the packager scripts and creates a spk/xsp file from it
1451
	Desc:	Loads the packager scripts and creates a spk/xsp file from it
1447
*/
1452
*/
1448
void LoadPackagerScript(const Utils::WString &filename, bool verify)
1453
void LoadPackagerScript(const Utils::CommandLine &cmd, bool verify)
1449
{
1454
{
-
 
1455
	Utils::WString filename = cmd.arg(1);
-
 
1456
	// check if the file exists in the current directory
-
 
1457
	if (!filename.contains(L":"))
-
 
1458
		filename = CDirIO(g_dir).file(filename);
-
 
1459
 
1450
	if ( !CFileIO::Exists(filename) )
1460
	if (!CFileIO::Exists(filename))
1451
	{
1461
	{
1452
		wprintf(L"Error: The packager script, %s, does not exist", filename.c_str());
1462
		wprintf(L"Error: The packager script, %s, does not exist", filename.c_str());
1453
		return;
1463
		return;
1454
	}
1464
	}
1455
 
1465
 
1456
	Utils::WString myDoc;
1466
	Utils::WString myDoc;
1457
#ifdef _WIN32
1467
#ifdef _WIN32
1458
	TCHAR pszPath[MAX_PATH];
1468
	TCHAR pszPath[MAX_PATH];
1459
	if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, pszPath)))
1469
	if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, pszPath)))
1460
	{
1470
	{
1461
		myDoc = (char *)pszPath;
1471
		myDoc = pszPath;
1462
	}
1472
	}
1463
#endif
1473
#endif
1464
 
1474
 
1465
	if ( verify )
1475
	if ( verify )
1466
		wprintf(L"Verifying Packager Script: %s\n", filename.c_str());
1476
		wprintf(L"Verifying Packager Script: %s\n", filename.c_str());
Line 1473... Line 1483...
1473
	if ( curDir.empty() ) curDir = L"./";
1483
	if ( curDir.empty() ) curDir = L"./";
1474
 
1484
 
1475
	Utils::WStringList variables;
1485
	Utils::WStringList variables;
1476
	variables.pushBack(L"$PATH", curDir);
1486
	variables.pushBack(L"$PATH", curDir);
1477
 
1487
 
1478
	CFileProgress info(&p, NULL, "Adding File");
1488
	CFileProgress info(&p, NULL, "Added File");
1479
	CBaseFile *package = p.loadPackagerScript(filename, -1, (verify) ? NULL : &GetAsk, &malformed, &unknown, &variables, &info);
1489
	CBaseFile *package = p.loadPackagerScript(filename, -1, (verify) ? NULL : &GetAsk, &malformed, &unknown, &variables, &info);
1480
 
1490
 
1481
	printf("\n");
1491
	printf("\n");
1482
 
1492
 
1483
	if ( verify )
1493
	if ( verify )
Line 1558... Line 1568...
1558
			}
1568
			}
1559
		}
1569
		}
1560
	}
1570
	}
1561
}
1571
}
1562
 
1572
 
-
 
1573
Utils::WString GetFileTypes()
-
 
1574
{
-
 
1575
	Utils::WString fileTypes;
-
 
1576
	for (int i = 0; i < FILETYPE_MAX; i++)
-
 
1577
	{
-
 
1578
		Utils::WString sT = GetFileTypeString(i);
-
 
1579
		if (!sT.empty())
-
 
1580
		{
-
 
1581
			if (fileTypes.empty())
-
 
1582
				fileTypes = sT;
-
 
1583
			else
-
 
1584
			{
-
 
1585
				fileTypes += L", ";
-
 
1586
				fileTypes += sT;
-
 
1587
			}
-
 
1588
		}
-
 
1589
	}
-
 
1590
	return fileTypes;
-
 
1591
}
-
 
1592
 
1563
/*
1593
/*
1564
	Main entry point to program
1594
	Main entry point to program
1565
*/
1595
*/
1566
int main ( int argc, char **argv )
1596
int main ( int argc, char **argv )
1567
{
1597
{
1568
	// display program header to command prompt
1598
	// display program header to command prompt
1569
	printf ( "\nSPKTool V1.50 (SPK File Version %.2f) 14/02/2021 Created by Cycrow\n\n", (float)FILEVERSION );
1599
	printf ( "\nSPKTool V1.51 (SPK File Version %.2f) 17/05/2025 Created by Cycrow\n\n", (float)FILEVERSION );
1570
 
1600
 
1571
	Utils::CommandLine cmd(argc, argv);
1601
	Utils::CommandLine cmd(argc, argv);
1572
	g_dir = cmd.cmdDir();
1602
	g_dir = cmd.cmdDir();
1573
	g_read = false;
1603
	g_read = false;
1574
 
1604
 
1575
	// not enough arguments, display the syntax and exit
1605
	// not enough arguments, display the syntax and exit
1576
	if ( argc < 2 )
1606
	if (cmd.argCount() < 1)
1577
	{
1607
	{
1578
		PrintSyntax(cmd.cmdName());
1608
		PrintSyntax(cmd.cmdName());
1579
		exit ( 1 );
1609
		exit ( 1 );
1580
	}
1610
	}
1581
 
1611
 
1582
	Utils::WString fileTypes;
-
 
1583
	for ( int i = 0; i < FILETYPE_MAX; i++ )
-
 
1584
	{
-
 
1585
		Utils::WString sT = GetFileTypeString(i);
-
 
1586
		if ( !sT.empty() )
-
 
1587
		{
-
 
1588
			if ( fileTypes.empty() )
-
 
1589
				fileTypes = sT;
-
 
1590
			else
-
 
1591
			{
-
 
1592
				fileTypes += L", ";
-
 
1593
				fileTypes += sT;
-
 
1594
			}
-
 
1595
		}
-
 
1596
	}
-
 
1597
 
-
 
1598
	// get the command flag
1612
	// get the command flag
1599
	Utils::WString command(argv[1]);
1613
	Utils::WString command(cmd.arg(0));
1600
 
1614
 
1601
	// display the contents of the spk file
1615
	// display the contents of the spk file
1602
	if ( command == L"-v" || command == L"-view" || command == L"-version")
1616
	if ( command == L"-v" || command == L"-view" || command == L"-version")
1603
	{
1617
	{
1604
		if ( argc < 3 )
1618
		if ( argc < 3 )
Line 1618... Line 1632...
1618
 
1632
 
1619
	// appends a file onto the spk archive
1633
	// appends a file onto the spk archive
1620
	else if ( command == L"-a" || command == L"-append" )
1634
	else if ( command == L"-a" || command == L"-append" )
1621
	{
1635
	{
1622
		if ( argc < 4 )
1636
		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.cmdName().c_str(), cmd.cmdName().c_str(), fileTypes.c_str() );
1637
			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(), GetFileTypes().c_str() );
1624
		else
1638
		else
1625
		{
1639
		{
1626
			Utils::WString arg4;
1640
			Utils::WString arg4;
1627
			if ( argc > 4 )
1641
			if ( argc > 4 )
1628
				arg4 = argv[4];
1642
				arg4 = argv[4];
Line 1633... Line 1647...
1633
	// removes a file from the spk archive
1647
	// removes a file from the spk archive
1634
	else if ( command == L"-r" || command == L"-remove" || command == L"-removespk" )
1648
	else if ( command == L"-r" || command == L"-remove" || command == L"-removespk" )
1635
	{
1649
	{
1636
		if ( argc < 4 )
1650
		if ( argc < 4 )
1637
		{
1651
		{
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() );
1652
			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(), GetFileTypes().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() );
1653
			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
		}
1654
		}
1641
		else
1655
		else
1642
		{
1656
		{
1643
			Utils::WString arg4;
1657
			Utils::WString arg4;
Line 1662... Line 1676...
1662
	}
1676
	}
1663
	else if ( command == L"-x" || command == L"-extract")
1677
	else if ( command == L"-x" || command == L"-extract")
1664
	{
1678
	{
1665
		if ( argc < 4 )
1679
		if ( argc < 4 )
1666
		{
1680
		{
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() );
1681
			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(), GetFileTypes().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() );
1682
			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
		}
1683
		}
1670
		else
1684
		else
1671
		{
1685
		{
1672
			Utils::WString arg5, arg4;
1686
			Utils::WString arg5, arg4;
Line 1750... Line 1764...
1750
			ConvertXsp(Utils::WString::FromString(argv[2]), arg3, (command == L"-convertxspwizard") ? true : false);
1764
			ConvertXsp(Utils::WString::FromString(argv[2]), arg3, (command == L"-convertxspwizard") ? true : false);
1751
		}
1765
		}
1752
	}
1766
	}
1753
	else if ( command == L"-createscript" )
1767
	else if ( command == L"-createscript" )
1754
	{
1768
	{
1755
		if ( argc < 3 )
1769
		if (cmd.argCount() < 2)
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() );
1770
			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
1771
		else
1758
			LoadPackagerScript ( argv[2], false );
1772
			LoadPackagerScript(cmd, false);
1759
	}
1773
	}
1760
	else if ( command == L"-generatescript" )
1774
	else if ( command == L"-generatescript" )
1761
	{
1775
	{
1762
		if ( argc < 3 )
1776
		if (cmd.argCount() < 2)
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() );
1777
			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
1778
		else
1765
		{
1779
		{
1766
			if ( argc < 4 )
1780
			if (cmd.argCount() < 3)
1767
				GeneratePackagerScript ( argv[2], "", 0);
1781
				GeneratePackagerScript ( argv[2], "", 0);
1768
			else
1782
			else
1769
				GeneratePackagerScript ( argv[2], argv[3], 0);
1783
				GeneratePackagerScript ( argv[2], argv[3], 0);
1770
		}
1784
		}
1771
	}
1785
	}
1772
	else if ( command == L"-verifyscript" )
1786
	else if ( command == L"-verifyscript" )
1773
	{
1787
	{
1774
		if ( argc < 3 )
1788
		if (cmd.argCount() < 2)
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() );
1789
			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
1790
		else
1777
			LoadPackagerScript ( argv[2], true );
1791
			LoadPackagerScript(cmd, true);
1778
	}
1792
	}
1779
	else if ( command == L"-extractship" )
1793
	else if ( command == L"-extractship" )
1780
	{
1794
	{
1781
		if ( argc < 4 )
1795
		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.cmdName().c_str() );
1796
			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() );