Subversion Repositories spk

Rev

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

Rev 101 Rev 102
Line 570... Line 570...
570
}
570
}
571
 
571
 
572
void CPackages::PurgeGameObjects()
572
void CPackages::PurgeGameObjects()
573
{
573
{
574
	// check for the log file
574
	// check for the log file
575
	CyString logDir = GetLogDirectory();
575
	Utils::String logDir = logDirectory();
576
	CFileIO LogFile(logDir + "/log0" + CyString::Number(PMTEXTFILE).PadNumber(4) + ".txt");
576
	CFileIO LogFile(logDir + "/log0" + Utils::String::PadNumber(PMTEXTFILE, 4) + ".txt");
577
	if ( LogFile.exists() )
577
	if ( LogFile.exists() )
578
	{
578
	{
579
		// read the log file to memory
579
		// read the log file to memory
580
		std::vector<CyString> *lines = LogFile.ReadLines();
580
		std::vector<CyString> *lines = LogFile.ReadLines();
581
		if ( lines )
581
		if ( lines )
Line 630... Line 630...
630
			node->Data()->iType = WARETYPE_NONE;
630
			node->Data()->iType = WARETYPE_NONE;
631
	}
631
	}
632
	m_lGameShips.RemoveEmpty();
632
	m_lGameShips.RemoveEmpty();
633
}
633
}
634
 
634
 
635
CyString CPackages::GetLogDirectory()
635
Utils::String CPackages::logDirectory()
636
{
636
{
637
	CyString logDir = m_sCurrentDir;
637
	Utils::String logDir = m_sCurrentDir.ToString();
638
	if ( m_iGameFlags & EXEFLAG_MYDOCLOG ) {
638
	if ( m_iGameFlags & EXEFLAG_MYDOCLOG ) {
639
		SGameExe *exe = m_gameExe.GetGame(m_iGame - 1);
639
		SGameExe *exe = m_gameExe.GetGame(m_iGame - 1);
640
		if ( exe ) {
640
		if ( exe ) {
641
			if ( !exe->sMyDoc.empty() )
641
			if ( !exe->sMyDoc.empty() )
642
				logDir = m_sMyDoc + "/" + exe->sMyDoc;
642
				logDir = m_sMyDoc.ToString() + "/" + exe->sMyDoc;
643
		}
643
		}
644
	}
644
	}
645
 
645
 
646
	return logDir;
646
	return logDir;
647
}
647
}
648
 
648
 
649
CyString CPackages::GetLogDirectory(CyString gameExe)
649
Utils::String CPackages::logDirectory(const Utils::String &gameExe)
650
{
650
{
651
	CyString logDir = m_sCurrentDir;
651
	Utils::String logDir = m_sCurrentDir.ToString();
652
	if ( m_iGameFlags & EXEFLAG_MYDOCLOG )
652
	if ( m_iGameFlags & EXEFLAG_MYDOCLOG )
653
	{
653
	{
654
		SGameExe *exe = m_gameExe.gameExe(CFileIO(gameExe).filename());
654
		SGameExe *exe = m_gameExe.gameExe(CFileIO(gameExe).filename());
655
		if ( exe )
655
		if ( exe )
656
		{
656
		{
657
			if ( !exe->sMyDoc.empty() )
657
			if ( !exe->sMyDoc.empty() )
658
				logDir = m_sMyDoc + "/" + exe->sMyDoc;
658
				logDir = m_sMyDoc.ToString() + "/" + exe->sMyDoc;
659
		}
659
		}
660
	}
660
	}
661
 
661
 
662
	return CFileIO(logDir).GetFullFilename();
662
	return CFileIO(logDir).fullFilename();
663
}
663
}
664
 
664
 
665
CyString CPackages::GetSaveDirectory()
665
Utils::String CPackages::saveDirectory()
666
{
666
{
667
	CyString logDir = this->GetLogDirectory();
667
	Utils::String logDir = this->logDirectory();
668
	if ( m_iGameFlags & EXEFLAG_NOSAVESUBDIR )
668
	if ( m_iGameFlags & EXEFLAG_NOSAVESUBDIR )
669
		return logDir;
669
		return logDir;
670
 
670
 
671
	return logDir + "/save";
671
	return logDir + "/save";
672
}
672
}
Line 810... Line 810...
810
 
810
 
811
	CFileIO catFile(m_sCurrentDir + "/" + filename + ".cat");
811
	CFileIO catFile(m_sCurrentDir + "/" + filename + ".cat");
812
	if ( catFile.exists() && CFileIO(m_sCurrentDir + "/" + filename + ".dat").ExistsOld() )
812
	if ( catFile.exists() && CFileIO(m_sCurrentDir + "/" + filename + ".dat").ExistsOld() )
813
	{
813
	{
814
		CCatFile openFile;
814
		CCatFile openFile;
815
		if ( openFile.Open(catFile.GetFullFilename(), this->GetAddonDir(), CATREAD_CATDECRYPT, false) == CATERR_NONE )
815
		if ( openFile.Open(catFile.fullFilename(), this->GetAddonDir(), CATREAD_CATDECRYPT, false) == CATERR_NONE )
816
		{
816
		{
817
//			if ( openFile.internaldatFilename().Compare("PlugMan_Fake.dat") ) return true;
817
//			if ( openFile.internaldatFilename().Compare("PlugMan_Fake.dat") ) return true;
818
			int count = 0;
818
			int count = 0;
819
			int noncount = 0;
819
			int noncount = 0;
820
 
820
 
Line 845... Line 845...
845
	// both the cat file and dat file exists, lets open it
845
	// both the cat file and dat file exists, lets open it
846
	CFileIO catFile(m_sCurrentDir + "/" + filename + ".cat");
846
	CFileIO catFile(m_sCurrentDir + "/" + filename + ".cat");
847
	if ( catFile.exists() && CFileIO(m_sCurrentDir + "/" + filename + ".dat").ExistsOld() )
847
	if ( catFile.exists() && CFileIO(m_sCurrentDir + "/" + filename + ".dat").ExistsOld() )
848
	{
848
	{
849
		CCatFile openFile;
849
		CCatFile openFile;
850
		if ( openFile.Open(catFile.GetFullFilename(), this->GetAddonDir(), CATREAD_CATDECRYPT, false) == CATERR_NONE )
850
		if ( openFile.Open(catFile.fullFilename(), this->GetAddonDir(), CATREAD_CATDECRYPT, false) == CATERR_NONE )
851
		{
851
		{
852
			if ( openFile.FindData("PlugMan\\TFake.pck") )
852
			if ( openFile.FindData("PlugMan\\TFake.pck") )
853
				return true;
853
				return true;
854
			if ( openFile.FindData("pluginmanagerfake.pck") )
854
			if ( openFile.FindData("pluginmanagerfake.pck") )
855
				return true;
855
				return true;
Line 1028... Line 1028...
1028
		this->LoadVirtualFileSystem();
1028
		this->LoadVirtualFileSystem();
1029
 
1029
 
1030
	// adjust save games
1030
	// adjust save games
1031
	if ( doStatus == -1 || doStatus == 3 )
1031
	if ( doStatus == -1 || doStatus == 3 )
1032
	{
1032
	{
1033
		/*
-
 
1034
		// load our save games to the active mydocs
-
 
1035
		if ( m_iSaveGame != -1 )
-
 
1036
		{
-
 
1037
			// check we have a valid save game directory
-
 
1038
			CDirIO Dir(this->GetSaveDirectory());
-
 
1039
			if ( Dir.Exists() )
-
 
1040
			{
-
 
1041
				// now check our directory already exists
-
 
1042
				// if we are vanilla mode, then make sure we use the vanilla saves if exists
-
 
1043
				CyString d = CyString("game_") + (long)m_iSaveGame + "/";
-
 
1044
				if ( m_bVanilla )
-
 
1045
					d += "Vanilla";
-
 
1046
				else
-
 
1047
					d += "Modified";
-
 
1048
 
-
 
1049
				// copy the files back over
-
 
1050
				if ( Dir.Exists(d) )
-
 
1051
				{
-
 
1052
					// if vanilla, remove files first
-
 
1053
					if ( m_bVanilla )
-
 
1054
					{
-
 
1055
						CyStringList *lDirs = Dir.DirList();
-
 
1056
						if ( lDirs )
-
 
1057
						{
-
 
1058
							for ( SStringList *node = lDirs->Head(); node; node = node->next )
-
 
1059
							{
-
 
1060
								if ( !Dir.IsFile(node->str) || !CFileIO(node->str).CheckFileExtension("sav") )
-
 
1061
									continue;
-
 
1062
								CFileIO(Dir.File(node->str)).Remove();
-
 
1063
							}
-
 
1064
 
-
 
1065
							delete lDirs;
-
 
1066
						}
-
 
1067
					}
-
 
1068
 
-
 
1069
					// copy files to normal save game directory
-
 
1070
					CDirIO FromDir(Dir.Dir(d));
-
 
1071
					CyStringList *lDirs = FromDir.DirList();
-
 
1072
					if ( lDirs )
-
 
1073
					{
-
 
1074
						for ( SStringList *node = lDirs->Head(); node; node = node->next )
-
 
1075
						{
-
 
1076
							if ( !FromDir.IsFile(node->str) || !CFileIO(node->str).CheckFileExtension("sav") )
-
 
1077
								continue;
-
 
1078
							CFileIO F(FromDir.File(node->str));
-
 
1079
							F.Copy(Dir.File(F.GetFilename()));
-
 
1080
						}
-
 
1081
 
-
 
1082
						delete lDirs;
-
 
1083
					}
-
 
1084
				}
-
 
1085
			}
-
 
1086
		}*/
-
 
1087
	}
1033
	}
1088
 
1034
 
1089
	m_bRedo = false;
1035
	m_bRedo = false;
1090
	return true;
1036
	return true;
1091
}
1037
}
Line 3047... Line 2993...
3047
		else
2993
		else
3048
		{
2994
		{
3049
			if ( newFile.exists() )
2995
			if ( newFile.exists() )
3050
				newFile.remove();
2996
				newFile.remove();
3051
 
2997
 
3052
			if ( !currentFile.Rename(newFile.GetFullFilename()) )
2998
			if ( !currentFile.Rename(newFile.fullFilename()) )
3053
			{
2999
			{
3054
				this->AddLogEntry(SPKINSTALL_ENABLEFILE_FAIL, newFilename, errors);
3000
				this->AddLogEntry(SPKINSTALL_ENABLEFILE_FAIL, newFilename, errors);
3055
				continue;
3001
				continue;
3056
			}
3002
			}
3057
		}
3003
		}
Line 4648... Line 4594...
4648
 
4594
 
4649
	if ( file->GetFilePointer().IsIn("::") ) {
4595
	if ( file->GetFilePointer().IsIn("::") ) {
4650
		CFileIO CatFile(file->GetFilePointer().GetToken("::", 1, 1));
4596
		CFileIO CatFile(file->GetFilePointer().GetToken("::", 1, 1));
4651
		if ( CatFile.exists() ) {
4597
		if ( CatFile.exists() ) {
4652
			CCatFile cat;
4598
			CCatFile cat;
4653
			if ( cat.Open(CatFile.GetFullFilename(), this->GetAddonDir(), CATREAD_DAT, false) == CATERR_NONE ) {
4599
			if ( cat.Open(CatFile.fullFilename(), this->GetAddonDir(), CATREAD_DAT, false) == CATERR_NONE ) {
4654
				CyString fileName = file->GetFilePointer().GetToken("::", 2, 2);
4600
				CyString fileName = file->GetFilePointer().GetToken("::", 2, 2);
4655
				if ( cat.FindData(fileName) ) {
4601
				if ( cat.FindData(fileName) ) {
4656
					if ( cat.RemoveFile(fileName) ) {
4602
					if ( cat.RemoveFile(fileName) ) {
4657
						this->AddLogEntry(SPKINSTALL_DELETEFILE, remFileStr, errors);
4603
						this->AddLogEntry(SPKINSTALL_DELETEFILE, remFileStr, errors);
4658
					}
4604
					}
Line 5501... Line 5447...
5501
 
5447
 
5502
	writeData.push_back(CyString("</language>"));
5448
	writeData.push_back(CyString("</language>"));
5503
	textFile.WriteFileUTF(&writeData);
5449
	textFile.WriteFileUTF(&writeData);
5504
 
5450
 
5505
	size_t fileSize;
5451
	size_t fileSize;
5506
	char *fileData = CFileIO(textFile.GetFullFilename()).ReadToData(&fileSize);
5452
	char *fileData = CFileIO(textFile.fullFilename()).ReadToData(&fileSize);
5507
 
5453
 
5508
	if ( fileData && fileSize)
5454
	if ( fileData && fileSize)
5509
	{
5455
	{
5510
		size_t newFileSize;
5456
		size_t newFileSize;
5511
		unsigned char *pckData = PCKData((unsigned char *)fileData, fileSize, &newFileSize, true);
5457
		unsigned char *pckData = PCKData((unsigned char *)fileData, fileSize, &newFileSize, true);
5512
		if ( pckData )
5458
		if ( pckData )
5513
		{
5459
		{
5514
			CFileIO pckFile(m_sCurrentDir + "/t/" + filename + ".pck");
5460
			CFileIO pckFile(m_sCurrentDir + "/t/" + filename + ".pck");
5515
			pckFile.WriteData((char *)pckData, newFileSize);
5461
			pckFile.WriteData((char *)pckData, newFileSize);
5516
			this->AddCreatedFile(pckFile.GetFullFilename());
5462
			this->AddCreatedFile(pckFile.fullFilename());
5517
		}
5463
		}
5518
	}
5464
	}
5519
	textFile.remove();
5465
	textFile.remove();
5520
}
5466
}
5521
 
5467
 
Line 5762... Line 5708...
5762
	}
5708
	}
5763
	writeData.push_back(CyString("</language>"));
5709
	writeData.push_back(CyString("</language>"));
5764
	textFile.WriteFileUTF(&writeData);
5710
	textFile.WriteFileUTF(&writeData);
5765
 
5711
 
5766
	size_t fileSize;
5712
	size_t fileSize;
5767
	char *fileData = CFileIO(textFile.GetFullFilename()).ReadToData(&fileSize);
5713
	char *fileData = CFileIO(textFile.fullFilename()).ReadToData(&fileSize);
5768
 
5714
 
5769
	if ( fileData && fileSize)
5715
	if ( fileData && fileSize)
5770
	{
5716
	{
5771
		size_t newFileSize;
5717
		size_t newFileSize;
5772
		unsigned char *pckData = PCKData((unsigned char *)fileData, fileSize, &newFileSize, true);
5718
		unsigned char *pckData = PCKData((unsigned char *)fileData, fileSize, &newFileSize, true);
5773
		if ( pckData )
5719
		if ( pckData )
5774
		{
5720
		{
5775
			CFileIO pckFile(m_sCurrentDir + "/t/" + filename + ".pck");
5721
			CFileIO pckFile(m_sCurrentDir + "/t/" + filename + ".pck");
5776
			pckFile.WriteData((char *)pckData, newFileSize);
5722
			pckFile.WriteData((char *)pckData, newFileSize);
5777
			this->AddCreatedFile(pckFile.GetFullFilename());
5723
			this->AddCreatedFile(pckFile.fullFilename());
5778
		}
5724
		}
5779
	}
5725
	}
5780
	textFile.remove();
5726
	textFile.remove();
5781
}
5727
}
5782
 
5728
 
Line 5798... Line 5744...
5798
}
5744
}
5799
 
5745
 
5800
void CPackages::BackupSaves(bool vanilla)
5746
void CPackages::BackupSaves(bool vanilla)
5801
{
5747
{
5802
	// copy any saves into the vanilla directory
5748
	// copy any saves into the vanilla directory
5803
	CyString dir = (vanilla) ? "Vanilla" : "Modified";
5749
	Utils::String dir = (vanilla) ? "Vanilla" : "Modified";
5804
 
5750
 
5805
	// make sure the directory exists
5751
	// make sure the directory exists
5806
	CDirIO saveDir(this->GetSaveDirectory());
5752
	CDirIO saveDir(this->saveDirectory());
5807
	CDirIO gameSaveDir(m_sCurrentDir);
5753
	CDirIO gameSaveDir(m_sCurrentDir);
5808
	if ( !gameSaveDir.Exists("PluginManager") )
5754
	if ( !gameSaveDir.Exists("PluginManager") )
5809
		gameSaveDir.Create("PluginManager");
5755
		gameSaveDir.Create("PluginManager");
5810
	gameSaveDir.cd("PluginManager");
5756
	gameSaveDir.cd("PluginManager");
5811
	if ( !gameSaveDir.Exists("Saves") )
5757
	if ( !gameSaveDir.Exists("Saves") )
Line 5838... Line 5784...
5838
}
5784
}
5839
 
5785
 
5840
void CPackages::RestoreSaves(bool vanilla)
5786
void CPackages::RestoreSaves(bool vanilla)
5841
{
5787
{
5842
	// get dir to restore from
5788
	// get dir to restore from
5843
	CyString dir = (vanilla) ? "Vanilla" : "Modified";
5789
	Utils::String dir = (vanilla) ? "Vanilla" : "Modified";
5844
	CDirIO restoreDir(m_sCurrentDir + "/PluginManager/Saves/" + dir);
5790
	CDirIO restoreDir(m_sCurrentDir + "/PluginManager/Saves/" + dir);
5845
	CDirIO toDir(this->GetSaveDirectory());
5791
	CDirIO toDir(this->saveDirectory());
5846
 
5792
 
5847
	//if we are in vanilla mode, we should remove the saves (so we only have vanilla saves
5793
	//if we are in vanilla mode, we should remove the saves (so we only have vanilla saves
5848
	if ( vanilla ) {
5794
	if ( vanilla ) {
5849
		CyStringList *files = toDir.DirList();
5795
		CyStringList *files = toDir.DirList();
5850
		if ( files ) {
5796
		if ( files ) {
Line 6514... Line 6460...
6514
		createFiles.PushBack(name, "types/Jobs");
6460
		createFiles.PushBack(name, "types/Jobs");
6515
		createFiles.PushBack(name, "types/JobWings");
6461
		createFiles.PushBack(name, "types/JobWings");
6516
 
6462
 
6517
		for ( SStringList *str = createFiles.Head(); str; str = str->next )
6463
		for ( SStringList *str = createFiles.Head(); str; str = str->next )
6518
		{
6464
		{
6519
			CyString dir = CFileIO(str->data).GetDir();
6465
			Utils::String dir = CFileIO(str->data).dir();
6520
			int type = FILETYPE_EXTRA;
6466
			int type = FILETYPE_EXTRA;
6521
			if ( dir.Compare("maps") )
6467
			if ( dir.Compare("maps") )
6522
				type = FILETYPE_MAP;
6468
				type = FILETYPE_MAP;
6523
 
6469
 
6524
			if ( !p->FindFile(str->str + ".xml", type) && !p->FindFile(str->str + ".pck", type) )
6470
			if ( !p->FindFile(str->str + ".xml", type) && !p->FindFile(str->str + ".pck", type) )
Line 6529... Line 6475...
6529
				{
6475
				{
6530
					CFileIO File((e == -1) ? (str->data + ".pck") : (m_sTempDir + "/" + str->data + ".pck"));
6476
					CFileIO File((e == -1) ? (str->data + ".pck") : (m_sTempDir + "/" + str->data + ".pck"));
6531
					if ( File.exists() )
6477
					if ( File.exists() )
6532
					{
6478
					{
6533
						File.Rename(m_sCurrentDir + "/" + dir + "/" + str->str + ".pck");
6479
						File.Rename(m_sCurrentDir + "/" + dir + "/" + str->str + ".pck");
6534
						this->AddCreatedFile(dir + "/" + str->str + ".pck");
6480
						this->AddCreatedFile(dir + "/" + str->str.ToString() + ".pck");
6535
					}
6481
					}
6536
				}
6482
				}
6537
			}
6483
			}
6538
		}
6484
		}
6539
	}
6485
	}
Line 7130... Line 7076...
7130
			if ( File.CheckFileExtension("bob") )
7076
			if ( File.CheckFileExtension("bob") )
7131
				ext = "pbb";
7077
				ext = "pbb";
7132
			else if ( File.CheckFileExtension("bod") )
7078
			else if ( File.CheckFileExtension("bod") )
7133
				ext = "pbd";
7079
				ext = "pbd";
7134
			CFileIO pckFile(File.ChangeFileExtension(ext));
7080
			CFileIO pckFile(File.ChangeFileExtension(ext));
7135
			if ( !CDirIO(pckFile.GetDir()).Exists() )
7081
			if ( !CDirIO(pckFile.dir()).Exists() )
7136
				CDirIO(pckFile.GetDir()).Create();
7082
				CDirIO(pckFile.dir()).Create();
7137
			pckFile.WriteData((char *)pckData, newFileSize);
7083
			pckFile.WriteData((char *)pckData, newFileSize);
7138
			return true;
7084
			return true;
7139
		}
7085
		}
7140
	}
7086
	}
7141
 
7087
 
Line 7162... Line 7108...
7162
			if ( File.CheckFileExtension("pbb") )
7108
			if ( File.CheckFileExtension("pbb") )
7163
				ext = "bob";
7109
				ext = "bob";
7164
			else if ( File.CheckFileExtension("pbd") )
7110
			else if ( File.CheckFileExtension("pbd") )
7165
				ext = "bod";
7111
				ext = "bod";
7166
			CFileIO pckFile(File.ChangeFileExtension(ext));
7112
			CFileIO pckFile(File.ChangeFileExtension(ext));
7167
			if ( !CDirIO(pckFile.GetDir()).Exists() )
7113
			if ( !CDirIO(pckFile.dir()).Exists() )
7168
				CDirIO(pckFile.GetDir()).Create();
7114
				CDirIO(pckFile.dir()).Create();
7169
			pckFile.WriteData((char *)pckData, newFileSize);
7115
			pckFile.WriteData((char *)pckData, newFileSize);
7170
 
7116
 
7171
			// check for xml and rename
7117
			// check for xml and rename
7172
			if ( checkxml )
7118
			if ( checkxml )
7173
			{
7119
			{
Line 7217... Line 7163...
7217
		CCatFile catFile;
7163
		CCatFile catFile;
7218
		int error = catFile.Open(m_sCurrentDir + "/mods/PluginManager.cat", this->GetAddonDir(), CATREAD_CATDECRYPT, true);
7164
		int error = catFile.Open(m_sCurrentDir + "/mods/PluginManager.cat", this->GetAddonDir(), CATREAD_CATDECRYPT, true);
7219
		if ( error == CATERR_NONE || error == CATERR_CREATED )
7165
		if ( error == CATERR_NONE || error == CATERR_CREATED )
7220
		{
7166
		{
7221
			// it it wrote ok, remove the old ones
7167
			// it it wrote ok, remove the old ones
7222
			if ( !catFile.AppendFile(File->GetFullFilename().ToString(), filename.ToString(), true, true) )
7168
			if ( !catFile.AppendFile(File->fullFilename(), filename.ToString(), true, true) )
7223
				return false;
7169
				return false;
7224
			return true;
7170
			return true;
7225
		}
7171
		}
7226
	}
7172
	}
7227
	else
7173
	else
7228
	{
7174
	{
7229
		// compress the file
7175
		// compress the file
7230
		size_t fileSize;
7176
		size_t fileSize;
7231
		char *fileData = CFileIO(File->GetFullFilename()).ReadToData(&fileSize);
7177
		char *fileData = CFileIO(File->fullFilename()).ReadToData(&fileSize);
7232
 
7178
 
7233
		if ( fileData && fileSize)
7179
		if ( fileData && fileSize)
7234
		{
7180
		{
7235
			size_t newFileSize;
7181
			size_t newFileSize;
7236
			unsigned char *pckData = PCKData((unsigned char *)fileData, fileSize, &newFileSize, true);
7182
			unsigned char *pckData = PCKData((unsigned char *)fileData, fileSize, &newFileSize, true);
7237
			if ( pckData )
7183
			if ( pckData )
7238
			{
7184
			{
7239
//				if ( !this->GetAddonDir().Empty() && CCatFile::IsAddonDir(filename) )
7185
//				if ( !this->GetAddonDir().Empty() && CCatFile::IsAddonDir(filename) )
7240
//					filename = this->GetAddonDir() + "/" + filename;
7186
//					filename = this->GetAddonDir() + "/" + filename;
7241
				CFileIO pckFile(m_sCurrentDir + "/" + filename);
7187
				CFileIO pckFile(m_sCurrentDir + "/" + filename);
7242
				if ( !CDirIO(pckFile.GetDir()).Exists() )
7188
				if ( !CDirIO(pckFile.dir()).Exists() )
7243
					CDirIO(pckFile.GetDir()).Create();
7189
					CDirIO(pckFile.dir()).Create();
7244
				pckFile.WriteData((char *)pckData, newFileSize);
7190
				pckFile.WriteData((char *)pckData, newFileSize);
7245
				this->AddCreatedFile(pckFile.GetFullFilename());
7191
				this->AddCreatedFile(pckFile.fullFilename());
7246
				return true;
7192
				return true;
7247
			}
7193
			}
7248
		}
7194
		}
7249
	}
7195
	}
7250
 
7196
 
Line 7534... Line 7480...
7534
			}
7480
			}
7535
 
7481
 
7536
			// current path
7482
			// current path
7537
			if ( rest.isin("$PATH") )
7483
			if ( rest.isin("$PATH") )
7538
			{
7484
			{
7539
				Utils::String currentDir = CFileIO(filename).GetDir().ToString();
7485
				Utils::String currentDir = CFileIO(filename).dir();
7540
				if ( !currentDir.empty() )
7486
				if ( !currentDir.empty() )
7541
					rest = rest.findReplace("$PATH", currentDir);
7487
					rest = rest.findReplace("$PATH", currentDir);
7542
			}
7488
			}
7543
 
7489
 
7544
			// now parse the rest of the values
7490
			// now parse the rest of the values
Line 8662... Line 8608...
8662
 
8608
 
8663
		CFileIO File(fileName);
8609
		CFileIO File(fileName);
8664
		if ( File.exists() )
8610
		if ( File.exists() )
8665
		{
8611
		{
8666
			if ( fileName.Compare("pluginmanager.txt") )
8612
			if ( fileName.Compare("pluginmanager.txt") )
8667
				this->ReadArchiveData(File.GetFullFilename(), archive);
8613
				this->ReadArchiveData(File.fullFilename(), archive);
8668
			else
8614
			else
8669
			{
8615
			{
8670
				CyString extradir;
8616
				CyString extradir;
8671
				int type = SPK::GetAutomaticFiletype(fileName, &extradir, true);
8617
				int type = SPK::GetAutomaticFiletype(fileName, &extradir, true);
8672
				// check for special file types
8618
				// check for special file types
8673
				C_File *f = NULL;
8619
				C_File *f = NULL;
8674
 
8620
 
8675
				if ( type == FILETYPE_SCRIPT_UNINSTALL ) {
8621
				if ( type == FILETYPE_SCRIPT_UNINSTALL ) {
8676
					f = archive->AddFile(CFileIO(fileName).GetFilename(), "", FILETYPE_SCRIPT);
8622
					f = archive->AddFile(CFileIO(fileName).GetFilename(), "", FILETYPE_SCRIPT);
8677
					if ( f ) {
8623
					if ( f ) {
8678
						f->ReadFromFile(File.GetFullFilename());
8624
						f->ReadFromFile(File.fullFilename());
8679
					}
8625
					}
8680
					type = FILETYPE_UNINSTALL;
8626
					type = FILETYPE_UNINSTALL;
8681
				}
8627
				}
8682
 
8628
 
8683
				if ( type == -1 )
8629
				if ( type == -1 )
8684
					f = archive->AddFile(CFileIO(fileName).GetFilename(), CFileIO(fileName).GetDir(), FILETYPE_EXTRA);
8630
					f = archive->AddFile(CFileIO(fileName).filename(), CFileIO(fileName).dir(), FILETYPE_EXTRA);
8685
				else
8631
				else
8686
					f = archive->AddFile(CFileIO(fileName).GetFilename(), extradir, type);
8632
					f = archive->AddFile(CFileIO(fileName).filename(), extradir, type);
8687
				f->ReadFromFile(File.GetFullFilename());
8633
				f->ReadFromFile(File.fullFilename());
8688
			}
8634
			}
8689
 
8635
 
8690
			File.remove();
8636
			File.remove();
8691
		}
8637
		}
8692
	}
8638
	}
Line 8765... Line 8711...
8765
 
8711
 
8766
			C_File *f = NULL;
8712
			C_File *f = NULL;
8767
 
8713
 
8768
			// check for special file types
8714
			// check for special file types
8769
			if ( type == FILETYPE_SCRIPT_UNINSTALL ) {
8715
			if ( type == FILETYPE_SCRIPT_UNINSTALL ) {
8770
				f = archive->AddFile(CFileIO(Name).GetFilename(), CFileIO(Name).GetDir(), FILETYPE_SCRIPT);
8716
				f = archive->AddFile(CFileIO(Name).filename(), CFileIO(Name).dir(), FILETYPE_SCRIPT);
8771
				if ( f ) {
8717
				if ( f ) {
8772
					f->copyData((const unsigned char *)iBuf, ze.unc_size);
8718
					f->copyData((const unsigned char *)iBuf, ze.unc_size);
8773
				}
8719
				}
8774
				type = FILETYPE_UNINSTALL;
8720
				type = FILETYPE_UNINSTALL;
8775
			}
8721
			}
8776
 
8722
 
8777
			if ( type == -1 )
8723
			if ( type == -1 )
8778
				f = archive->AddFile(CFileIO(Name).GetFilename(), CFileIO(Name).GetDir(), FILETYPE_EXTRA);
8724
				f = archive->AddFile(CFileIO(Name).filename(), CFileIO(Name).dir(), FILETYPE_EXTRA);
8779
			else
8725
			else
8780
				f = archive->AddFile(CFileIO(Name).GetFilename(), extradir, type);
8726
				f = archive->AddFile(CFileIO(Name).filename(), extradir, type);
8781
 
8727
 
8782
			if ( f )
8728
			if ( f )
8783
				f->SetData((const unsigned char *)iBuf, ze.unc_size);
8729
				f->SetData((const unsigned char *)iBuf, ze.unc_size);
8784
			else
8730
			else
8785
				delete[] iBuf;
8731
				delete[] iBuf;
Line 8816... Line 8762...
8816
	return archive;
8762
	return archive;
8817
}
8763
}
8818
 
8764
 
8819
CyString CPackages::CreateFromPackagerScript(CyString filename)
8765
CyString CPackages::CreateFromPackagerScript(CyString filename)
8820
{
8766
{
8821
	CyString curDir = CFileIO(filename).GetDir();
8767
	CyString curDir = CFileIO(filename).dir();
8822
	CyStringList variables;
8768
	CyStringList variables;
8823
	variables.PushBack("$PATH", curDir);
8769
	variables.PushBack("$PATH", curDir);
8824
	CPackages p;
8770
	CPackages p;
8825
	CBaseFile *package = p.LoadPackagerScript(filename, NULL, NULL, NULL, &variables);
8771
	CBaseFile *package = p.LoadPackagerScript(filename, NULL, NULL, NULL, &variables);
8826
 
8772
 
Line 8839... Line 8785...
8839
 
8785
 
8840
	// write script
8786
	// write script
8841
	if ( package->WriteFile(saveto) )
8787
	if ( package->WriteFile(saveto) )
8842
	{
8788
	{
8843
		if ( package->AutoGenerateUpdateFile() )
8789
		if ( package->AutoGenerateUpdateFile() )
8844
			package->CreateUpdateFile(CFileIO(saveto).GetDir());
8790
			package->CreateUpdateFile(CFileIO(saveto).dir());
8845
		return saveto;
8791
		return saveto;
8846
	}
8792
	}
8847
 
8793
 
8848
	return NullString;
8794
	return NullString;
8849
}
8795
}