Subversion Repositories spk

Rev

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

Rev 129 Rev 131
Line 1364... Line 1364...
1364
/*
1364
/*
1365
	Func:	LoadPackagerScript
1365
	Func:	LoadPackagerScript
1366
	Args:	String filename	-	The filename of the packager script to load
1366
	Args:	String filename	-	The filename of the packager script to load
1367
	Desc:	Loads the packager scripts and creates a spk/xsp file from it
1367
	Desc:	Loads the packager scripts and creates a spk/xsp file from it
1368
*/
1368
*/
1369
void LoadPackagerScript(CyString filename, bool verify)
1369
void LoadPackagerScript(const Utils::String &filename, bool verify)
1370
{
1370
{
1371
	if ( !CFileIO(filename).ExistsOld() )
1371
	if ( !CFileIO::Exists(filename) )
1372
	{
1372
	{
1373
		printf("Error: The packager script, %s, does not exist", filename.c_str());
1373
		printf("Error: The packager script, %s, does not exist", filename.c_str());
1374
		return;
1374
		return;
1375
	}
1375
	}
1376
 
1376
 
1377
	CyString myDoc;
1377
	Utils::String myDoc;
1378
#ifdef _WIN32
1378
#ifdef _WIN32
1379
	TCHAR pszPath[MAX_PATH];
1379
	TCHAR pszPath[MAX_PATH];
1380
	if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, pszPath)))
1380
	if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, pszPath)))
1381
	{
1381
	{
1382
		myDoc = (char *)pszPath;
1382
		myDoc = (char *)pszPath;
Line 1385... Line 1385...
1385
 
1385
 
1386
	if ( verify )
1386
	if ( verify )
1387
		printf("Verifying Packager Script: %s\n", filename.c_str());
1387
		printf("Verifying Packager Script: %s\n", filename.c_str());
1388
 
1388
 
1389
	CPackages p;
1389
	CPackages p;
1390
	p.Startup(".", ".", myDoc);
1390
	p.startup(".", ".", myDoc);
1391
	CyStringList malformed, unknown;
1391
	Utils::CStringList malformed, unknown;
1392
 
1392
 
1393
	CyString curDir = CFileIO(filename).dir();
1393
	Utils::String curDir = CFileIO(filename).dir();
1394
	if ( curDir.Empty() ) curDir = "./";
1394
	if ( curDir.empty() ) curDir = "./";
1395
 
1395
 
1396
	CyStringList variables;
1396
	Utils::CStringList variables;
1397
	variables.PushBack("$PATH", curDir);
1397
	variables.pushBack("$PATH", curDir);
1398
 
1398
 
1399
	CBaseFile *package = p.LoadPackagerScript(filename, -1, (verify) ? NULL : &GetAsk, &malformed, &unknown, &variables);
1399
	CBaseFile *package = p.LoadPackagerScript(filename, -1, (verify) ? NULL : &GetAsk, &malformed, &unknown, &variables);
1400
 
1400
 
1401
	if ( verify )
1401
	if ( verify )
1402
	{
1402
	{
1403
		if ( !malformed.Empty() )
1403
		if ( !malformed.empty() )
1404
		{
1404
		{
1405
			printf("Malformed Lines (%d):\n", malformed.Count());
1405
			printf("Malformed Lines (%d):\n", malformed.size());
1406
			for ( SStringList *strNode = malformed.Head(); strNode; strNode = strNode->;next )
1406
			for(auto itr = malformed.begin(); itr != malformed.end(); itr++)				
1407
				printf("\t(Line %3d) %s\n", strNode->data.ToInt(), strNode->str.c_str());
1407
				printf("\t(Line %3d) %s\n", (*itr)->data.toInt(), (*itr)->str.c_str());
1408
		}
1408
		}
1409
		if ( !unknown.Empty() )
1409
		if ( !unknown.empty() )
1410
		{
1410
		{
1411
			printf("Unknown Commands (%d):\n", unknown.Count());
1411
			printf("Unknown Commands (%d):\n", unknown.size());
1412
			for ( SStringList *strNode = unknown.Head(); strNode; strNode = strNode->next )
1412
			for (auto itr = unknown.begin(); itr != unknown.end(); itr++)
1413
				printf("\t* Command: %s = %s\n", strNode->str.c_str(), strNode->data.c_str());
1413
				printf("\t* Command: %s = %s\n", (*itr)->str.c_str(), (*itr)->data.c_str());
1414
		}
1414
		}
1415
	}
1415
	}
1416
 
1416
 
1417
	if ( !package )
1417
	if ( !package )
1418
	{
1418
	{
Line 1421... Line 1421...
1421
		else
1421
		else
1422
			printf("Error: Unable to create package, from script: %s\n", filename.c_str());
1422
			printf("Error: Unable to create package, from script: %s\n", filename.c_str());
1423
	}
1423
	}
1424
	else
1424
	else
1425
	{
1425
	{
1426
		CyString saveto = package->filename();
1426
		Utils::String saveto = package->filename();
1427
		saveto = saveto.FindReplace("$DEFAULTDIR", curDir + "/");
1427
		saveto = saveto.findReplace("$DEFAULTDIR", curDir + "/");
1428
		saveto = saveto.FindReplace("$PATH", curDir);
1428
		saveto = saveto.findReplace("$PATH", curDir);
1429
		saveto = saveto.FindReplace("\\", "/");
1429
		saveto = saveto.findReplace("\\", "/");
1430
		saveto = saveto.FindReplace("//", "/");
1430
		saveto = saveto.findReplace("//", "/");
1431
		if ( !saveto.Right(4).Compare(".spk") && package->GetType() != TYPE_XSP )
1431
		if ( !saveto.right(4).Compare(".spk") && package->GetType() != TYPE_XSP )
1432
			saveto += ".spk";
1432
			saveto += ".spk";
1433
		else if ( !saveto.Right(4).Compare(".xsp") && package->GetType() == TYPE_XSP )
1433
		else if ( !saveto.right(4).Compare(".xsp") && package->GetType() == TYPE_XSP )
1434
			saveto += ".xsp";
1434
			saveto += ".xsp";
1435
		printf("Saving file to: %s\n", CFileIO(saveto).fullFilename().c_str());
1435
		printf("Saving file to: %s\n", CFileIO(saveto).fullFilename().c_str());
1436
		if ( verify )
1436
		if ( verify )
1437
			printf("Package can be created from this script\n");
1437
			printf("Package can be created from this script\n");
1438
		else
1438
		else
Line 1447... Line 1447...
1447
			else
1447
			else
1448
				printf("Error! There was a problem writing the package\n");
1448
				printf("Error! There was a problem writing the package\n");
1449
		}
1449
		}
1450
 
1450
 
1451
		saveto = package->exportFilename();
1451
		saveto = package->exportFilename();
1452
		if ( !saveto.Empty() ) {
1452
		if ( !saveto.empty() ) {
1453
			saveto = saveto.FindReplace("$DEFAULTDIR", curDir + "/");
1453
			saveto = saveto.findReplace("$DEFAULTDIR", curDir + "/");
1454
			saveto = saveto.FindReplace("$PATH", curDir);
1454
			saveto = saveto.findReplace("$PATH", curDir);
1455
			saveto = saveto.FindReplace("\\", "/");
1455
			saveto = saveto.findReplace("\\", "/");
1456
			saveto = saveto.FindReplace("//", "/");
1456
			saveto = saveto.findReplace("//", "/");
1457
			printf("Exporting file to: %s\n", CFileIO(saveto).fullFilename().c_str());
1457
			printf("Exporting file to: %s\n", CFileIO(saveto).fullFilename().c_str());
1458
			if ( verify )
1458
			if ( verify )
1459
				printf("Package can be exported from this script\n");
1459
				printf("Package can be exported from this script\n");
1460
			else
1460
			else
1461
			{
1461
			{