Subversion Repositories spk

Rev

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

Rev 51 Rev 52
Line 142... Line 142...
142
{
142
{
143
	bool oldPlugin = false;
143
	bool oldPlugin = false;
144
 
144
 
145
	dir = dir.FindReplace("\\", "/");
145
	dir = dir.FindReplace("\\", "/");
146
	CFileIO datFile(dir + "/PluginManager/pluginmanager.dat");
146
	CFileIO datFile(dir + "/PluginManager/pluginmanager.dat");
147
	if ( datFile.Exists() )
147
	if ( datFile.exists() )
148
	{
148
	{
149
		std::vector<CyString> *readFile = datFile.ReadLines();
149
		std::vector<CyString> *readFile = datFile.ReadLines();
150
		if ( readFile )
150
		if ( readFile )
151
		{
151
		{
152
			for ( int i = 0; i < (int)readFile->size(); i++ )
152
			for ( int i = 0; i < (int)readFile->size(); i++ )
Line 187... Line 187...
187
 
187
 
188
	m_bVanilla = true;
188
	m_bVanilla = true;
189
 
189
 
190
	// check the pluginmanager data file exists
190
	// check the pluginmanager data file exists
191
	CFileIO datFile(m_sCurrentDir + "/PluginManager/pluginmanager.dat");
191
	CFileIO datFile(m_sCurrentDir + "/PluginManager/pluginmanager.dat");
192
	if ( datFile.Exists() )
192
	if ( datFile.exists() )
193
	{
193
	{
194
		std::vector<CyString> *readFile = datFile.ReadLines();
194
		std::vector<CyString> *readFile = datFile.ReadLines();
195
		if ( readFile )
195
		if ( readFile )
196
		{
196
		{
197
			float fVersion = 0;
197
			float fVersion = 0;
Line 447... Line 447...
447
					uf->SetFilename(m_sCurrentDir + "/Scripts/" + rest.GetToken(" ", 2));
447
					uf->SetFilename(m_sCurrentDir + "/Scripts/" + rest.GetToken(" ", 2));
448
					m_lUninstallFiles.push_back(uf);
448
					m_lUninstallFiles.push_back(uf);
449
				}
449
				}
450
				else if ( cmd == "NonRemovedFile" )
450
				else if ( cmd == "NonRemovedFile" )
451
				{
451
				{
452
					if ( !CFileIO(rest).Remove() )
452
					if ( !CFileIO::Remove(rest.ToString()) )
453
						m_lNonRemovedFiles.PushBack(rest);
453
						m_lNonRemovedFiles.PushBack(rest);
454
				}
454
				}
455
				else if ( cmd == "Original" )
455
				else if ( cmd == "Original" )
456
				{
456
				{
457
					C_File *uf = new C_File();
457
					C_File *uf = new C_File();
Line 544... Line 544...
544
 
544
 
545
void CPackages::RemoveCreatedFiles()
545
void CPackages::RemoveCreatedFiles()
546
{
546
{
547
	for ( SStringList *node = m_lCreatedFiles.Head(); node; node = node->next )
547
	for ( SStringList *node = m_lCreatedFiles.Head(); node; node = node->next )
548
	{
548
	{
549
		if ( CFileIO(node->str).Exists() )
549
		if ( CFileIO(node->str).ExistsOld() )
550
			CFileIO(node->str).Remove();
550
			CFileIO::Remove(node->str.ToString());
551
		else if ( CFileIO(m_sCurrentDir + "/" + node->str).Exists() )
551
		else if ( CFileIO(m_sCurrentDir + "/" + node->str).ExistsOld() )
552
			CFileIO(m_sCurrentDir + "/" + node->str).Remove();
552
			CFileIO::Remove((m_sCurrentDir + "/" + node->str).ToString());
553
	}
553
	}
554
 
554
 
555
	m_lCreatedFiles.Clear();
555
	m_lCreatedFiles.Clear();
556
}
556
}
557
 
557
 
558
void CPackages::PurgeGameObjects()
558
void CPackages::PurgeGameObjects()
559
{
559
{
560
	// check for the log file
560
	// check for the log file
561
	CyString logDir = GetLogDirectory();
561
	CyString logDir = GetLogDirectory();
562
	CFileIO LogFile(logDir + "/log0" + CyString::Number(PMTEXTFILE).PadNumber(4) + ".txt");
562
	CFileIO LogFile(logDir + "/log0" + CyString::Number(PMTEXTFILE).PadNumber(4) + ".txt");
563
	if ( LogFile.Exists() )
563
	if ( LogFile.exists() )
564
	{
564
	{
565
		// read the log file to memory
565
		// read the log file to memory
566
		std::vector<CyString> *lines = LogFile.ReadLines();
566
		std::vector<CyString> *lines = LogFile.ReadLines();
567
		if ( lines )
567
		if ( lines )
568
		{
568
		{
Line 584... Line 584...
584
			}
584
			}
585
 
585
 
586
			delete lines;
586
			delete lines;
587
		}
587
		}
588
		// remove the log file
588
		// remove the log file
589
		LogFile.Remove();
589
		LogFile.remove();
590
	}
590
	}
591
}
591
}
592
 
592
 
593
void CPackages::PurgeWares()
593
void CPackages::PurgeWares()
594
{
594
{
Line 660... Line 660...
660
}
660
}
661
 
661
 
662
bool CPackages::ReadyFakePatch()
662
bool CPackages::ReadyFakePatch()
663
{
663
{
664
	// already exists, lets skip it
664
	// already exists, lets skip it
665
	if ( CFileIO(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat").Exists() && CFileIO(m_sCurrentDir + "/PluginManager/PlugMan_Fake.dat").Exists() )
665
	if ( CFileIO(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat").ExistsOld() && CFileIO(m_sCurrentDir + "/PluginManager/PlugMan_Fake.dat").ExistsOld() )
666
		return true;
666
		return true;
667
 
667
 
668
	// if only one of them exists, lets remove them
668
	// if only one of them exists, lets remove them
669
	if ( CFileIO(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat").Exists() )
669
	if ( CFileIO(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat").ExistsOld() )
670
		CFileIO(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat").Remove();
670
		CFileIO::Remove(m_sCurrentDir.ToString() + "/PluginManager/PlugMan_Fake.cat");
671
	if ( CFileIO(m_sCurrentDir + "/PluginManager/PlugMan_Fake.dat").Exists() )
671
	if ( CFileIO(m_sCurrentDir + "/PluginManager/PlugMan_Fake.dat").ExistsOld() )
672
		CFileIO(m_sCurrentDir + "/PluginManager/PlugMan_Fake.dat").Remove();
672
		CFileIO::Remove(m_sCurrentDir.ToString() + "/PluginManager/PlugMan_Fake.dat");
673
 
673
 
674
	// now lets find the fake patch
674
	// now lets find the fake patch
675
	CyString useFile;
675
	CyString useFile;
676
	if ( m_iFakePatch > 0 )
676
	if ( m_iFakePatch > 0 )
677
	{
677
	{
Line 748... Line 748...
748
 
748
 
749
			// no files, jsut delete them
749
			// no files, jsut delete them
750
			CFileIO catFile(m_sCurrentDir + "/" + useFile + ".cat");
750
			CFileIO catFile(m_sCurrentDir + "/" + useFile + ".cat");
751
			if ( !files || !found )
751
			if ( !files || !found )
752
			{
752
			{
753
				if ( catFile.Remove() )
753
				if ( catFile.remove() )
754
				{
754
				{
755
					CFileIO datFile(m_sCurrentDir + "/" + useFile + ".dat");
755
					CFileIO datFile(m_sCurrentDir + "/" + useFile + ".dat");
756
					if ( datFile.Remove() )
756
					if ( datFile.remove() )
757
						return true;
757
						return true;
758
				}
758
				}
759
			}
759
			}
760
			else
760
			else
761
			{
761
			{
Line 783... Line 783...
783
bool CPackages::CheckIfPluginManagerFile(CyString filename)
783
bool CPackages::CheckIfPluginManagerFile(CyString filename)
784
{
784
{
785
	bool found = false;
785
	bool found = false;
786
 
786
 
787
	CFileIO catFile(m_sCurrentDir + "/" + filename + ".cat");
787
	CFileIO catFile(m_sCurrentDir + "/" + filename + ".cat");
788
	if ( catFile.Exists() && CFileIO(m_sCurrentDir + "/" + filename + ".dat").Exists() )
788
	if ( catFile.exists() && CFileIO(m_sCurrentDir + "/" + filename + ".dat").ExistsOld() )
789
	{
789
	{
790
		CCatFile openFile;
790
		CCatFile openFile;
791
		if ( openFile.Open(catFile.GetFullFilename(), this->GetAddonDir(), CATREAD_CATDECRYPT, false) == CATERR_NONE )
791
		if ( openFile.Open(catFile.GetFullFilename(), this->GetAddonDir(), CATREAD_CATDECRYPT, false) == CATERR_NONE )
792
		{
792
		{
793
			int count = 0;
793
			int count = 0;
Line 819... Line 819...
819
{
819
{
820
	bool found = false;
820
	bool found = false;
821
 
821
 
822
	// both the cat file and dat file exists, lets open it
822
	// both the cat file and dat file exists, lets open it
823
	CFileIO catFile(m_sCurrentDir + "/" + filename + ".cat");
823
	CFileIO catFile(m_sCurrentDir + "/" + filename + ".cat");
824
	if ( catFile.Exists() && CFileIO(m_sCurrentDir + "/" + filename + ".dat").Exists() )
824
	if ( catFile.exists() && CFileIO(m_sCurrentDir + "/" + filename + ".dat").ExistsOld() )
825
	{
825
	{
826
		CCatFile openFile;
826
		CCatFile openFile;
827
		if ( openFile.Open(catFile.GetFullFilename(), this->GetAddonDir(), CATREAD_CATDECRYPT, false) == CATERR_NONE )
827
		if ( openFile.Open(catFile.GetFullFilename(), this->GetAddonDir(), CATREAD_CATDECRYPT, false) == CATERR_NONE )
828
		{
828
		{
829
			if ( openFile.FindData("PlugMan\\TFake.pck") )
829
			if ( openFile.FindData("PlugMan\\TFake.pck") )
Line 1074... Line 1074...
1074
}
1074
}
1075
 
1075
 
1076
int CPackages::CheckOpenPackage(CyString file, int *error)
1076
int CPackages::CheckOpenPackage(CyString file, int *error)
1077
{
1077
{
1078
	// first check if it exists
1078
	// first check if it exists
1079
	if ( !CFileIO(file).Exists() )
1079
	if ( !CFileIO(file).ExistsOld() )
1080
	{
1080
	{
1081
		*error = INSTALLERR_NOEXIST;
1081
		*error = INSTALLERR_NOEXIST;
1082
		return -1;
1082
		return -1;
1083
	}
1083
	}
1084
 
1084
 
Line 1352... Line 1352...
1352
			CLog::logf(CLog::Log_Install, 4, "File: %s", f->Data()->GetFilePointer().c_str());
1352
			CLog::logf(CLog::Log_Install, 4, "File: %s", f->Data()->GetFilePointer().c_str());
1353
			if ( f->Data()->GetFileType() != FILETYPE_SHIPSCENE && f->Data()->GetFileType() != FILETYPE_COCKPITSCENE && f->Data()->GetFileType() != FILETYPE_SHIPMODEL && f->Data()->GetFileType() != FILETYPE_SHIPOTHER ) {
1353
			if ( f->Data()->GetFileType() != FILETYPE_SHIPSCENE && f->Data()->GetFileType() != FILETYPE_COCKPITSCENE && f->Data()->GetFileType() != FILETYPE_SHIPMODEL && f->Data()->GetFileType() != FILETYPE_SHIPOTHER ) {
1354
				CLog::logf(CLog::Log_Install, 4, "Not a valid file type to add to fake patch (%d)", f->Data()->GetFileType());
1354
				CLog::logf(CLog::Log_Install, 4, "Not a valid file type to add to fake patch (%d)", f->Data()->GetFileType());
1355
				continue;
1355
				continue;
1356
			}
1356
			}
-
 
1357
			CLog::logf(CLog::Log_Install, 4, "checking addon dir");
1357
			if ( CCatFile::IsAddonDir(f->Data()->GetNameDirectory(pPackage)) ) {
1358
			if ( CCatFile::IsAddonDir(f->Data()->GetNameDirectory(pPackage)) ) {
1358
				CLog::logf(CLog::Log_Install, 4, "Is an addon directory, skipping, %s", f->Data()->GetNameDirectory(pPackage).c_str());
1359
				CLog::logf(CLog::Log_Install, 4, "Is an addon directory, skipping, %s", f->Data()->GetNameDirectory(pPackage).c_str());
1359
				continue;
1360
				continue;
1360
			}
1361
			}
1361
			// check if its already in the fake patch
1362
			// check if its already in the fake patch
-
 
1363
			CLog::logf(CLog::Log_Install, 4, "checking full dir");
1362
			if ( f->Data()->GetFullDir().IsIn("::") ) {
1364
			if ( f->Data()->GetFullDir().IsIn("::") ) {
1363
				CLog::logf(CLog::Log_Install, 4, "Is already in a mod file, skipping, %s", f->Data()->GetNameDirectory(pPackage).c_str());
1365
				CLog::logf(CLog::Log_Install, 4, "Is already in a mod file, skipping, %s", f->Data()->GetNameDirectory(pPackage).c_str());
1364
				continue;
1366
				continue;
1365
			}
1367
			}
1366
			CyString toFile;
1368
			Utils::String toFile;
1367
			CLog::logf(CLog::Log_Install, 2, "Adding file: %s into the fake patch", f->Data()->GetNameDirectory(pPackage).c_str());
1369
			CLog::logf(CLog::Log_Install, 2, "Adding file: %s into the fake patch", f->Data()->GetNameDirectory(pPackage).c_str());
-
 
1370
			CLog::logf(CLog::Log_Install, 4, "Cat File: %s", cat.GetCatFilename().c_str());
-
 
1371
 
-
 
1372
			Utils::String sFilename = f->Data()->GetFilePointer().ToString();
-
 
1373
			CLog::logf(CLog::Log_Install, 4, "- Filename: %s", sFilename.c_str());
-
 
1374
			Utils::String sTo = f->Data()->GetNameDirectory(pPackage).ToString();
-
 
1375
			CLog::logf(CLog::Log_Install, 4, "- To: %s", sTo.c_str());
1368
			if ( cat.AppendFile(f->Data()->GetFilePointer(), f->Data()->GetNameDirectory(pPackage), true, (m_iGameFlags & EXEFLAG_NOXOR) ? false : true, &toFile) ) {
1376
			if ( cat.AppendFile(sFilename, sTo, true, (m_iGameFlags & EXEFLAG_NOXOR) ? false : true, &toFile) ) {
1369
				CLog::logf(CLog::Log_Install, 3, "Removing old file, %s", f->Data()->GetFilePointer().c_str());
1377
				CLog::logf(CLog::Log_Install, 3, "Removing old file, %s", f->Data()->GetFilePointer().c_str());
1370
				CFileIO(f->Data()->GetFilePointer()).Remove();
1378
				CFileIO::Remove(f->Data()->GetFilePointer().ToString());
1371
				CLog::logf(CLog::Log_Install, 3, "Adjusting file pointer to fake patch, %s => %s", f->Data()->GetFilePointer().c_str(), (m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat::" + toFile).c_str());
1379
				CLog::logf(CLog::Log_Install, 3, "Adjusting file pointer to fake patch, %s => %s", f->Data()->GetFilePointer().c_str(), (m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat::" + toFile).c_str());
1372
				f->Data()->SetFilename(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat::" + toFile);
1380
				f->Data()->SetFilename(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat::" + toFile);
1373
			}
1381
			}
1374
		}
1382
		}
1375
	}
1383
	}
Line 1555... Line 1563...
1555
						if ( catTo.Open(findMatching->GetFilePointer(), this->GetAddonDir(), CATREAD_CATDECRYPT, false) == CATERR_NONE )
1563
						if ( catTo.Open(findMatching->GetFilePointer(), this->GetAddonDir(), CATREAD_CATDECRYPT, false) == CATERR_NONE )
1556
						{
1564
						{
1557
							for ( int i = 0; i < catFrom.GetNumFiles(); i++ )
1565
							for ( int i = 0; i < catFrom.GetNumFiles(); i++ )
1558
							{
1566
							{
1559
								SInCatFile *c = catFrom.GetFile(i);								 
1567
								SInCatFile *c = catFrom.GetFile(i);								 
1560
								catTo.AppendFile(f->Data()->GetFilePointer() + "::" + c->sFile, c->sFile);
1568
								catTo.AppendFile((f->Data()->GetFilePointer() + "::" + c->sFile).ToString(), c->sFile.ToString());
1561
							}
1569
							}
1562
						}
1570
						}
1563
					}
1571
					}
1564
 
1572
 
1565
					// now remove the files
1573
					// now remove the files
Line 1849... Line 1857...
1849
		{
1857
		{
1850
			// check if its an original file and restore
1858
			// check if its an original file and restore
1851
			if ( IsOriginalFile(f) )
1859
			if ( IsOriginalFile(f) )
1852
			{
1860
			{
1853
				CFileIO of(m_sCurrentDir + "/PluginManager/Original/" + f->GetNameDirectory(NULL));
1861
				CFileIO of(m_sCurrentDir + "/PluginManager/Original/" + f->GetNameDirectory(NULL));
1854
				if ( of.Exists() )
1862
				if ( of.exists() )
1855
				{
1863
				{
1856
					original = true;
1864
					original = true;
1857
					if ( of.Rename(m_sCurrentDir + "/" + f->GetNameDirectory(NULL)) )
1865
					if ( of.Rename(m_sCurrentDir + "/" + f->GetNameDirectory(NULL)) )
1858
						this->AddLogEntry(SPKINSTALL_ORIGINAL_RESTORE, f->GetNameDirectory(NULL), errors);
1866
						this->AddLogEntry(SPKINSTALL_ORIGINAL_RESTORE, f->GetNameDirectory(NULL), errors);
1859
					else
1867
					else
Line 1919... Line 1927...
1919
			CyString newFilename = m_sCurrentDir + "/" + newFile->GetNameDirectory(NULL);
1927
			CyString newFilename = m_sCurrentDir + "/" + newFile->GetNameDirectory(NULL);
1920
			CFileIO file(uf->GetFilePointer());
1928
			CFileIO file(uf->GetFilePointer());
1921
 
1929
 
1922
			if ( uf->GetUsed() )
1930
			if ( uf->GetUsed() )
1923
			{
1931
			{
1924
				if ( file.Copy(newFilename) )
1932
				if ( file.copy(newFilename.ToString()) )
1925
					this->AddLogEntry(SPKINSTALL_UNINSTALL_COPY, newFile->GetNameDirectory(NULL), errors);
1933
					this->AddLogEntry(SPKINSTALL_UNINSTALL_COPY, newFile->GetNameDirectory(NULL), errors);
1926
				else
1934
				else
1927
				{
1935
				{
1928
					this->AddLogEntry(SPKINSTALL_UNINSTALL_COPY_FAIL, newFile->GetNameDirectory(NULL), errors);
1936
					this->AddLogEntry(SPKINSTALL_UNINSTALL_COPY_FAIL, newFile->GetNameDirectory(NULL), errors);
1929
					delete newFile;
1937
					delete newFile;
Line 2428... Line 2436...
2428
	if ( m_bRenameText )
2436
	if ( m_bRenameText )
2429
		CreateLanguageTextFiles(errors);
2437
		CreateLanguageTextFiles(errors);
2430
 
2438
 
2431
	this->BackupSaves();
2439
	this->BackupSaves();
2432
 
2440
 
2433
	if ( CFileIO(m_sCurrentDir + "/mods/PluginManager.dat").Exists() )
2441
	if ( CFileIO(m_sCurrentDir + "/mods/PluginManager.dat").ExistsOld() )
2434
		CFileIO(m_sCurrentDir + "/mods/PluginManager.dat").Remove();
2442
		CFileIO::Remove(m_sCurrentDir.ToString() + "/mods/PluginManager.dat");
2435
	if ( CFileIO(m_sCurrentDir + "/mods/PluginManager.cat").Exists() )
2443
	if ( CFileIO(m_sCurrentDir + "/mods/PluginManager.cat").ExistsOld() )
2436
		CFileIO(m_sCurrentDir + "/mods/PluginManager.cat").Remove();
2444
		CFileIO::Remove(m_sCurrentDir.ToString() + "/mods/PluginManager.cat");
2437
 
2445
 
2438
	if ( !m_bVanilla )
2446
	if ( !m_bVanilla )
2439
	{
2447
	{
2440
		// base mode for Reunion
2448
		// base mode for Reunion
2441
		if ( m_iGame == GAME_X3 && m_pEnabledMod )
2449
		if ( m_iGame == GAME_X3 && m_pEnabledMod )
Line 2450... Line 2458...
2450
				while ( fCat && !fCat->IsFakePatch() && !fCat->CheckFileExt("cat") && !fCat->GetBaseName().Compare(fDat->GetBaseName()) )
2458
				while ( fCat && !fCat->IsFakePatch() && !fCat->CheckFileExt("cat") && !fCat->GetBaseName().Compare(fDat->GetBaseName()) )
2451
					fCat = m_pEnabledMod->GetNextFile(fCat);
2459
					fCat = m_pEnabledMod->GetNextFile(fCat);
2452
 
2460
 
2453
				if ( fCat )
2461
				if ( fCat )
2454
				{
2462
				{
2455
					CFileIO(fDat->GetFilePointer()).Copy(m_sCurrentDir + "/mods/PluginManager.dat");
2463
					CFileIO(fDat->GetFilePointer()).copy(m_sCurrentDir.ToString() + "/mods/PluginManager.dat");
2456
					CFileIO(fCat->GetFilePointer()).Copy(m_sCurrentDir + "/mods/PluginManager.cat");
2464
					CFileIO(fCat->GetFilePointer()).copy(m_sCurrentDir.ToString() + "/mods/PluginManager.cat");
2457
				}
2465
				}
2458
			}
2466
			}
2459
		}
2467
		}
2460
		else if ( m_iGame == GAME_X3 && !m_sSetMod.Empty() && CFileIO(m_sCurrentDir + "/mods/" + m_sSetMod + ".cat").Exists() && CFileIO(m_sCurrentDir + "/mods/" + m_sSetMod + ".dat").Exists() )
2468
		else if ( m_iGame == GAME_X3 && !m_sSetMod.Empty() && CFileIO(m_sCurrentDir + "/mods/" + m_sSetMod + ".cat").ExistsOld() && CFileIO(m_sCurrentDir + "/mods/" + m_sSetMod + ".dat").ExistsOld() )
2461
		{
2469
		{
2462
			CFileIO(m_sCurrentDir + "/mods/" + m_sSetMod + ".dat").Copy(m_sCurrentDir + "/mods/PluginManager.dat");
2470
			CFileIO(m_sCurrentDir + "/mods/" + m_sSetMod + ".dat").copy(m_sCurrentDir.ToString() + "/mods/PluginManager.dat");
2463
			CFileIO(m_sCurrentDir + "/mods/" + m_sSetMod + ".cat").Copy(m_sCurrentDir + "/mods/PluginManager.cat");
2471
			CFileIO(m_sCurrentDir + "/mods/" + m_sSetMod + ".cat").copy(m_sCurrentDir.ToString() + "/mods/PluginManager.cat");
2464
		}
2472
		}
2465
 
2473
 
2466
		if ( !CDirIO(m_sCurrentDir).Exists("mods") )
2474
		if ( !CDirIO(m_sCurrentDir).Exists("mods") )
2467
			CDirIO(m_sCurrentDir).Create("mods");
2475
			CDirIO(m_sCurrentDir).Create("mods");
2468
 
2476
 
Line 2529... Line 2537...
2529
 
2537
 
2530
	CFileIO catFile(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat");
2538
	CFileIO catFile(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat");
2531
	CFileIO datFile(m_sCurrentDir + "/PluginManager/PlugMan_Fake.dat");
2539
	CFileIO datFile(m_sCurrentDir + "/PluginManager/PlugMan_Fake.dat");
2532
 
2540
 
2533
	// if only 1 exists, remove it
2541
	// if only 1 exists, remove it
2534
	if ( catFile.Exists() && !datFile.Exists() )
2542
	if ( catFile.exists() && !datFile.exists() ) {
2535
	{
-
 
2536
		if ( !catFile.Remove() )
2543
		if ( !catFile.remove() ) return false;
2537
			return false;
-
 
2538
	}
2544
	}
2539
	else if ( !catFile.Exists() && datFile.Exists() )
2545
	else if ( !catFile.exists() && datFile.exists() ) {
2540
	{
-
 
2541
		if ( !datFile.Remove() )
2546
		if ( !datFile.remove() ) return false;
2542
			return false;
-
 
2543
	}
2547
	}
2544
 
2548
 
2545
	// if both exists, lets rename them
2549
	// if both exists, lets rename them
2546
	if ( catFile.Exists() && datFile.Exists() )
2550
	if ( catFile.exists() && datFile.exists() )
2547
	{
2551
	{
2548
		// we need to add the plugin manager file in
2552
		// we need to add the plugin manager file in
2549
		CyString file = m_sTempDir;
2553
		CyString file = m_sTempDir;
2550
		if ( !file.Empty() )
2554
		if ( !file.Empty() )
2551
			file += "/";
2555
			file += "/";
Line 2557... Line 2561...
2557
		fakeFile.WriteFile(&lines);
2561
		fakeFile.WriteFile(&lines);
2558
 
2562
 
2559
		CCatFile fakePatch;
2563
		CCatFile fakePatch;
2560
		if ( fakePatch.Open(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat", this->GetAddonDir(), CATREAD_DAT, false) == CATERR_NONE )
2564
		if ( fakePatch.Open(m_sCurrentDir + "/PluginManager/PlugMan_Fake.cat", this->GetAddonDir(), CATREAD_DAT, false) == CATERR_NONE )
2561
		{
2565
		{
2562
			if ( fakePatch.AppendFile(file, "PlugMan\\TFake.pck") )
2566
			if ( fakePatch.AppendFile(file.ToString(), "PlugMan\\TFake.pck") )
2563
			{
2567
			{
2564
				// find next available fake patch
2568
				// find next available fake patch
2565
				m_iFakePatch = this->FindNextFakePatch();
2569
				m_iFakePatch = this->FindNextFakePatch();
2566
 
2570
 
2567
				CyString filename = CyString::Number(m_iFakePatch).PadNumber(2);
2571
				CyString filename = CyString::Number(m_iFakePatch).PadNumber(2);
2568
				if ( catFile.Rename(m_sCurrentDir + "/" + filename + ".cat") )
2572
				if ( catFile.Rename(m_sCurrentDir + "/" + filename + ".cat") )
2569
				{
2573
				{
2570
					if ( datFile.Rename(m_sCurrentDir + "/" + filename + ".dat") )
2574
					if ( datFile.Rename(m_sCurrentDir + "/" + filename + ".dat") ){
2571
					{
-
 
2572
						fakeFile.Remove();
2575
						fakeFile.remove();
2573
						return true;
2576
						return true;
2574
					}
2577
					}
2575
 
2578
 
2576
					// TODO: restore cat file
2579
					// TODO: restore cat file
2577
				}
2580
				}
2578
			}
2581
			}
2579
		}
2582
		}
2580
 
2583
 
2581
		fakeFile.Remove();
2584
		fakeFile.remove();
2582
		return false;
2585
		return false;
2583
	}
2586
	}
2584
 
2587
 
2585
	return true;
2588
	return true;
2586
}
2589
}
Line 2952... Line 2955...
2952
		// check if theres an original file to backup
2955
		// check if theres an original file to backup
2953
		C_File *of = GetOriginalFile(f);
2956
		C_File *of = GetOriginalFile(f);
2954
		if ( of )
2957
		if ( of )
2955
		{
2958
		{
2956
			// check if the orignal file is already backed up
2959
			// check if the orignal file is already backed up
2957
			if ( !CFileIO(m_sCurrentDir + "/PluginManager/Original/" + f->GetNameDirectory(package)).Exists() )
2960
			if ( !CFileIO(m_sCurrentDir + "/PluginManager/Original/" + f->GetNameDirectory(package)).ExistsOld() )
2958
			{
2961
			{
2959
				// lets back up the file now
2962
				// lets back up the file now
2960
				BackupOriginalFile(of, errors);
2963
				BackupOriginalFile(of, errors);
2961
			}
2964
			}
2962
		}
2965
		}
Line 2985... Line 2988...
2985
 
2988
 
2986
		// lets actually move the file back now
2989
		// lets actually move the file back now
2987
		// !!error checking!!
2990
		// !!error checking!!
2988
		CFileIO currentFile(f->GetFilePointer());
2991
		CFileIO currentFile(f->GetFilePointer());
2989
		CFileIO newFile(m_sCurrentDir + "/" + newFilename);
2992
		CFileIO newFile(m_sCurrentDir + "/" + newFilename);
2990
		if ( !currentFile.Exists() )
2993
		if ( !currentFile.exists() )
2991
		{
2994
		{
2992
			// missing file ??
2995
			// missing file ??
2993
			if ( !newFile.Exists() )
2996
			if ( !newFile.exists() )
2994
			{
2997
			{
2995
				this->AddLogEntry(SPKINSTALL_MISSINGFILE, newFilename, errors);
2998
				this->AddLogEntry(SPKINSTALL_MISSINGFILE, newFilename, errors);
2996
				continue;
2999
				continue;
2997
			}
3000
			}
2998
		}
3001
		}
2999
		// remove existing file
3002
		// remove existing file
3000
		// file exists, so lets try to move it
3003
		// file exists, so lets try to move it
3001
		else
3004
		else
3002
		{
3005
		{
3003
			if ( newFile.Exists() )
3006
			if ( newFile.exists() )
3004
				newFile.Remove();
3007
				newFile.remove();
3005
 
3008
 
3006
			if ( !currentFile.Rename(newFile.GetFullFilename()) )
3009
			if ( !currentFile.Rename(newFile.GetFullFilename()) )
3007
			{
3010
			{
3008
				this->AddLogEntry(SPKINSTALL_ENABLEFILE_FAIL, newFilename, errors);
3011
				this->AddLogEntry(SPKINSTALL_ENABLEFILE_FAIL, newFilename, errors);
3009
				continue;
3012
				continue;
Line 3180... Line 3183...
3180
 
3183
 
3181
		// now to move the file by renameing it to its new location
3184
		// now to move the file by renameing it to its new location
3182
		// !!error checking!!
3185
		// !!error checking!!
3183
		// check the file, if it doesn't exist, and exists as disabled, we should just adjust the setting instead of an error
3186
		// check the file, if it doesn't exist, and exists as disabled, we should just adjust the setting instead of an error
3184
		CFileIO currentFile(f->GetFilePointer());
3187
		CFileIO currentFile(f->GetFilePointer());
3185
		if ( !currentFile.Exists() )
3188
		if ( !currentFile.exists() )
3186
		{
3189
		{
3187
			if ( !CFileIO(newFilename).Exists() )
3190
			if ( !CFileIO(newFilename).exists() )
3188
			{
3191
			{
3189
				this->AddLogEntry(SPKINSTALL_MISSINGFILE, f->GetNameDirectory(checkPackage), errors);
3192
				this->AddLogEntry(SPKINSTALL_MISSINGFILE, f->GetNameDirectory(checkPackage), errors);
3190
				continue;
3193
				continue;
3191
			}
3194
			}
3192
		}
3195
		}
Line 3202... Line 3205...
3202
 
3205
 
3203
		// check if its an original file and restore
3206
		// check if its an original file and restore
3204
		if ( IsOriginalFile(f) )
3207
		if ( IsOriginalFile(f) )
3205
		{
3208
		{
3206
			CFileIO of(m_sCurrentDir + "/PluginManager/Original/" + f->GetNameDirectory(checkPackage));
3209
			CFileIO of(m_sCurrentDir + "/PluginManager/Original/" + f->GetNameDirectory(checkPackage));
3207
			if ( of.Exists() )
3210
			if ( of.exists() )
3208
			{
3211
			{
3209
				original = true;
3212
				original = true;
3210
				if ( of.Rename(m_sCurrentDir + "/" + f->GetNameDirectory(checkPackage)) )
3213
				if ( of.Rename(m_sCurrentDir + "/" + f->GetNameDirectory(checkPackage)) )
3211
					this->AddLogEntry(SPKINSTALL_ORIGINAL_RESTORE, f->GetNameDirectory(checkPackage), errors);
3214
					this->AddLogEntry(SPKINSTALL_ORIGINAL_RESTORE, f->GetNameDirectory(checkPackage), errors);
3212
				else
3215
				else
Line 3776... Line 3779...
3776
 * Removes a single uninstall file
3779
 * Removes a single uninstall file
3777
 */
3780
 */
3778
bool CPackages::RemoveUninstallFile(C_File *file, CyStringList *errors)
3781
bool CPackages::RemoveUninstallFile(C_File *file, CyStringList *errors)
3779
{
3782
{
3780
	CFileIO fio(file->GetFilePointer());
3783
	CFileIO fio(file->GetFilePointer());
3781
	if ( fio.Exists() )
3784
	if ( fio.exists() )
3782
	{
3785
	{
3783
		if ( fio.Remove() )
3786
		if ( fio.remove() ) {
3784
		{
-
 
3785
			this->AddLogEntry(SPKINSTALL_UNINSTALL_REMOVE, file->GetNameDirectory(NULL), errors);
3787
			this->AddLogEntry(SPKINSTALL_UNINSTALL_REMOVE, file->GetNameDirectory(NULL), errors);
3786
			return true;
3788
			return true;
3787
		}
3789
		}
3788
		else if ( errors )
3790
		else if ( errors )
3789
			this->AddLogEntry(SPKINSTALL_UNINSTALL_REMOVE_FAIL, file->GetNameDirectory(NULL), errors);
3791
			this->AddLogEntry(SPKINSTALL_UNINSTALL_REMOVE_FAIL, file->GetNameDirectory(NULL), errors);
Line 3849... Line 3851...
3849
 * Removes a single file
3851
 * Removes a single file
3850
 */
3852
 */
3851
bool CPackages::RemoveSharedFile(C_File *file, CyStringList *errors)
3853
bool CPackages::RemoveSharedFile(C_File *file, CyStringList *errors)
3852
{
3854
{
3853
	CFileIO fio(file->GetFilePointer());
3855
	CFileIO fio(file->GetFilePointer());
3854
	if ( fio.Exists() )
3856
	if ( fio.exists() )
3855
	{
3857
	{
3856
		if ( fio.Remove() )
3858
		if ( fio.remove() ) {
3857
		{
-
 
3858
			this->AddLogEntry(SPKINSTALL_SHARED, file->GetNameDirectory(NULL), errors);
3859
			this->AddLogEntry(SPKINSTALL_SHARED, file->GetNameDirectory(NULL), errors);
3859
			delete file;
3860
			delete file;
3860
			return true;
3861
			return true;
3861
		}
3862
		}
3862
		else if ( errors )
3863
		else if ( errors )
Line 4078... Line 4079...
4078
		this->AddLogEntry(SPKINSTALL_CREATEDIRECTORY, newDir, errors);
4079
		this->AddLogEntry(SPKINSTALL_CREATEDIRECTORY, newDir, errors);
4079
	}
4080
	}
4080
 
4081
 
4081
	// now lets copy the file
4082
	// now lets copy the file
4082
	CFileIO CopyFile(f->GetFilePointer());
4083
	CFileIO CopyFile(f->GetFilePointer());
4083
	if ( CopyFile.Copy(oDir.File(newDir + "/" + f->GetFilename())) )
4084
	if ( CopyFile.copy(oDir.File(newDir + "/" + f->GetFilename()).ToString()) )
4084
	{
4085
	{
4085
		CLog::logf(CLog::Log_Install, 2, "Original file: %s has been backed up", f->GetNameDirectory(NULL).c_str());
4086
		CLog::logf(CLog::Log_Install, 2, "Original file: %s has been backed up", f->GetNameDirectory(NULL).c_str());
4086
		this->AddLogEntry(SPKINSTALL_ORIGINAL_BACKUP, f->GetNameDirectory(NULL), errors);
4087
		this->AddLogEntry(SPKINSTALL_ORIGINAL_BACKUP, f->GetNameDirectory(NULL), errors);
4087
		return true;
4088
		return true;
4088
	}
4089
	}
Line 4281... Line 4282...
4281
				// check its filename, it might already be in the correct place
4282
				// check its filename, it might already be in the correct place
4282
				if ( lowestFile->GetBaseName().ToInt() != lowest )
4283
				if ( lowestFile->GetBaseName().ToInt() != lowest )
4283
				{
4284
				{
4284
					// if the file already exists, we need to move it elsewhere
4285
					// if the file already exists, we need to move it elsewhere
4285
					CyString nextName = CyString::Number(lowest).PadNumber(2);
4286
					CyString nextName = CyString::Number(lowest).PadNumber(2);
4286
					if ( CFileIO(m_sCurrentDir + "/" + nextName + ".cat").Exists() )
4287
					if ( CFileIO(m_sCurrentDir + "/" + nextName + ".cat").ExistsOld() )
4287
					{
4288
					{
4288
						// find the file in our internal file list
4289
						// find the file in our internal file list
4289
						C_File *moveFile = FindFile(FILETYPE_MOD, nextName + ".cat");
4290
						C_File *moveFile = FindFile(FILETYPE_MOD, nextName + ".cat");
4290
						if ( !moveFile ) // must not have it in our list ? lets move to the next
4291
						if ( !moveFile ) // must not have it in our list ? lets move to the next
4291
						{
4292
						{
Line 4772... Line 4773...
4772
	CyString remFileStr = file->GetFilePointer();
4773
	CyString remFileStr = file->GetFilePointer();
4773
	remFileStr.FindReplace(m_sCurrentDir, "");
4774
	remFileStr.FindReplace(m_sCurrentDir, "");
4774
 
4775
 
4775
	if ( file->GetFilePointer().IsIn("::") ) {
4776
	if ( file->GetFilePointer().IsIn("::") ) {
4776
		CFileIO CatFile(file->GetFilePointer().GetToken("::", 1, 1));
4777
		CFileIO CatFile(file->GetFilePointer().GetToken("::", 1, 1));
4777
		if ( CatFile.Exists() ) {
4778
		if ( CatFile.exists() ) {
4778
			CCatFile cat;
4779
			CCatFile cat;
4779
			if ( cat.Open(CatFile.GetFullFilename(), this->GetAddonDir(), CATREAD_DAT, false) == CATERR_NONE ) {
4780
			if ( cat.Open(CatFile.GetFullFilename(), this->GetAddonDir(), CATREAD_DAT, false) == CATERR_NONE ) {
4780
				CyString fileName = file->GetFilePointer().GetToken("::", 2, 2);
4781
				CyString fileName = file->GetFilePointer().GetToken("::", 2, 2);
4781
				if ( cat.FindData(fileName) ) {
4782
				if ( cat.FindData(fileName) ) {
4782
					if ( cat.RemoveFile(fileName) ) {
4783
					if ( cat.RemoveFile(fileName) ) {
Line 4790... Line 4791...
4790
			}
4791
			}
4791
		}
4792
		}
4792
	}
4793
	}
4793
	else {
4794
	else {
4794
		CFileIO f(file->GetFilePointer());
4795
		CFileIO f(file->GetFilePointer());
4795
		if ( f.Exists() )
4796
		if ( f.exists() )
4796
		{
4797
		{
4797
			if ( f.Remove() )
-
 
4798
				this->AddLogEntry(SPKINSTALL_DELETEFILE, remFileStr, errors);
4798
			if ( f.remove() ) this->AddLogEntry(SPKINSTALL_DELETEFILE, remFileStr, errors);
4799
			else if ( errors )
4799
			else if ( errors )
4800
			{
4800
			{
4801
				this->AddLogEntry(SPKINSTALL_DELETEFILE_FAIL, remFileStr, errors);
4801
				this->AddLogEntry(SPKINSTALL_DELETEFILE_FAIL, remFileStr, errors);
4802
				return false;
4802
				return false;
4803
			}
4803
			}
Line 4835... Line 4835...
4835
			progress->UpdateProgress(files, max);
4835
			progress->UpdateProgress(files, max);
4836
		++files;
4836
		++files;
4837
 
4837
 
4838
		C_File *f = oNode->Data();
4838
		C_File *f = oNode->Data();
4839
		CFileIO of(m_sCurrentDir + "/PluginManager/Original/" + f->GetNameDirectory(NULL));
4839
		CFileIO of(m_sCurrentDir + "/PluginManager/Original/" + f->GetNameDirectory(NULL));
4840
		if ( of.Exists() )
4840
		if ( of.exists() )
4841
			of.Rename(m_sCurrentDir + "/" + f->GetNameDirectory(NULL));
4841
			of.Rename(m_sCurrentDir + "/" + f->GetNameDirectory(NULL));
4842
 
4842
 
4843
		//RemoveFile(oNode->Data());
4843
		//RemoveFile(oNode->Data());
4844
		delete oNode->Data();
4844
		delete oNode->Data();
4845
	}
4845
	}
Line 4944... Line 4944...
4944
	m_gameExe.Reset();
4944
	m_gameExe.Reset();
4945
 
4945
 
4946
	CyString exeFile = this->FindDataDir(dir, "exe");
4946
	CyString exeFile = this->FindDataDir(dir, "exe");
4947
 
4947
 
4948
	// if file exists, read it, otherwise, just add
4948
	// if file exists, read it, otherwise, just add
4949
	if ( !exeFile.Empty() && CFileIO(exeFile).Exists() )
4949
	if ( !exeFile.Empty() && CFileIO(exeFile).ExistsOld() )
4950
		m_gameExe.ReadFile(exeFile);
4950
		m_gameExe.ReadFile(exeFile);
4951
	else
4951
	else
4952
	{
4952
	{
4953
		m_gameExe.ParseExe("x2.exe:5:NOSAVESUBDIR:HKCU/Software/EgoSoftware/X2/ModName:X2 The Threat:!GAMEDIR!:2:1604608!2150400:1.4 Artifical Life:1974272:1.5 Uplink");
4953
		m_gameExe.ParseExe("x2.exe:5:NOSAVESUBDIR:HKCU/Software/EgoSoftware/X2/ModName:X2 The Threat:!GAMEDIR!:2:1604608!2150400:1.4 Artifical Life:1974272:1.5 Uplink");
4954
		m_gameExe.ParseExe("x3.exe:5:0:HKCU/Software/Egosoft/X3/ModName:X3 Reunion:Egosoft/X3:2:2347008:2.0 Bala Gi:2367488!2375680:2.5 Uplink");
4954
		m_gameExe.ParseExe("x3.exe:5:0:HKCU/Software/Egosoft/X3/ModName:X3 Reunion:Egosoft/X3:2:2347008:2.0 Bala Gi:2367488!2375680:2.5 Uplink");
Line 5107... Line 5107...
5107
			}
5107
			}
5108
		}
5108
		}
5109
	}
5109
	}
5110
	else if ( !m_sSetMod.Empty() )
5110
	else if ( !m_sSetMod.Empty() )
5111
	{
5111
	{
5112
		if ( CFileIO(m_sCurrentDir + "/mods/" + m_sSetMod + ".cat").Exists() )
5112
		if ( CFileIO(m_sCurrentDir + "/mods/" + m_sSetMod + ".cat").ExistsOld() )
5113
		{
5113
		{
5114
			CCatFile catFile;
5114
			CCatFile catFile;
5115
			if ( catFile.Open(m_sCurrentDir + "/mods/" + m_sSetMod + ".cat", addonDir, CATREAD_CATDECRYPT, false) == CATERR_NONE )
5115
			if ( catFile.Open(m_sCurrentDir + "/mods/" + m_sSetMod + ".cat", addonDir, CATREAD_CATDECRYPT, false) == CATERR_NONE )
5116
			{
5116
			{
5117
				if ( catFile.ExtractFile(aFilename, aTo) )
5117
				if ( catFile.ExtractFile(aFilename, aTo) )
Line 5125... Line 5125...
5125
		}
5125
		}
5126
	}
5126
	}
5127
 
5127
 
5128
	// find the highest cat number
5128
	// find the highest cat number
5129
	int catNumber = 1;
5129
	int catNumber = 1;
5130
	while ( CFileIO(dir + "/" + CyString::Number(catNumber).PadNumber(2) + ".cat").Exists() && catNumber < 99 )
5130
	while ( CFileIO(dir + "/" + CyString::Number(catNumber).PadNumber(2) + ".cat").ExistsOld() && catNumber < 99 )
5131
		++catNumber;
5131
		++catNumber;
5132
 
5132
 
5133
	// get the last one, not the next free one
5133
	// get the last one, not the next free one
5134
	--catNumber;
5134
	--catNumber;
5135
 
5135
 
Line 5169... Line 5169...
5169
		wareFile += (char)UPPER(wareType);
5169
		wareFile += (char)UPPER(wareType);
5170
 
5170
 
5171
		CyString openFile;
5171
		CyString openFile;
5172
 
5172
 
5173
		int e;
5173
		int e;
5174
		if ( i == WARES_TECH && CFileIO(m_sTempDir + "/TWareT.txt").Exists() )
5174
		if ( i == WARES_TECH && CFileIO(m_sTempDir + "/TWareT.txt").ExistsOld() )
5175
			openFile = m_sTempDir + "/TWareT.txt";
5175
			openFile = m_sTempDir + "/TWareT.txt";
5176
		else {
5176
		else {
5177
			e = ExtractGameFile(CyString("types/") + wareFile + ".pck", m_sTempDir + "/" + wareFile + ".txt");
5177
			e = ExtractGameFile(CyString("types/") + wareFile + ".pck", m_sTempDir + "/" + wareFile + ".txt");
5178
			if ( e == 1 )
5178
			if ( e == 1 )
5179
				openFile = m_sTempDir + "/" + wareFile + ".txt";
5179
				openFile = m_sTempDir + "/" + wareFile + ".txt";
Line 5270... Line 5270...
5270
					wareLines.PushFront(CyString("// Created by SPKInstaller Libraries V") + strV, NullString);
5270
					wareLines.PushFront(CyString("// Created by SPKInstaller Libraries V") + strV, NullString);
5271
					if ( readFile.WriteFile(&wareLines) )
5271
					if ( readFile.WriteFile(&wareLines) )
5272
						this->PackFile(&readFile, CyString("types\\") + wareFile + ".pck");
5272
						this->PackFile(&readFile, CyString("types\\") + wareFile + ".pck");
5273
				}
5273
				}
5274
			}
5274
			}
5275
			readFile.Remove();
5275
			readFile.remove();
5276
		}
5276
		}
5277
	}
5277
	}
5278
}
5278
}
5279
 
5279
 
5280
void CPackages::CreateEMPFile(CyString progDir)
5280
void CPackages::CreateEMPFile(CyString progDir)
Line 5740... Line 5740...
5740
			CFileIO pckFile(m_sCurrentDir + "/t/" + filename + ".pck");
5740
			CFileIO pckFile(m_sCurrentDir + "/t/" + filename + ".pck");
5741
			pckFile.WriteData((char *)pckData, newFileSize);
5741
			pckFile.WriteData((char *)pckData, newFileSize);
5742
			this->AddCreatedFile(pckFile.GetFullFilename());
5742
			this->AddCreatedFile(pckFile.GetFullFilename());
5743
		}
5743
		}
5744
	}
5744
	}
5745
	textFile.Remove();
5745
	textFile.remove();
5746
}
5746
}
5747
 
5747
 
5748
bool CPackages::IsCurrentDir(CyString dir)
5748
bool CPackages::IsCurrentDir(CyString dir)
5749
{
5749
{
5750
	if ( dir.Compare(m_sCurrentDir) )
5750
	if ( dir.Compare(m_sCurrentDir) )
Line 5789... Line 5789...
5789
			CFileIO File(saveDir.File(node->str));
5789
			CFileIO File(saveDir.File(node->str));
5790
			if ( !File.CheckFileExtension("sav") )
5790
			if ( !File.CheckFileExtension("sav") )
5791
				continue;
5791
				continue;
5792
			// remove the file if already exists
5792
			// remove the file if already exists
5793
			if ( gameSaveDir.Exists(node->str) )
5793
			if ( gameSaveDir.Exists(node->str) )
5794
				CFileIO(gameSaveDir.File(node->str)).Remove();
5794
				CFileIO::Remove(gameSaveDir.File(node->str).ToString());
5795
 
5795
 
5796
			// copy the file into the games save dir for backup
5796
			// copy the file into the games save dir for backup
5797
			File.Copy(gameSaveDir.File(File.GetFilename()), true);
5797
			File.copy(gameSaveDir.File(File.GetFilename()).ToString(), true);
5798
		}
5798
		}
5799
 
5799
 
5800
		delete dirs;
5800
		delete dirs;
5801
	}
5801
	}
5802
 
5802
 
Line 5814... Line 5814...
5814
	{
5814
	{
5815
		for ( SStringList *node = dirs->Head(); node; node = node->next )
5815
		for ( SStringList *node = dirs->Head(); node; node = node->next )
5816
		{
5816
		{
5817
			CFileIO File(restoreDir.File(node->str));
5817
			CFileIO File(restoreDir.File(node->str));
5818
			// remove the file if already exists
5818
			// remove the file if already exists
5819
			if ( toDir.Exists(node->str) )
-
 
5820
				CFileIO(toDir.File(node->str)).Remove();
5819
			if ( toDir.Exists(node->str) ) CFileIO::Remove(toDir.File(node->str).ToString());
5821
 
5820
 
5822
			// move file over
5821
			// move file over
5823
			File.Copy(toDir.File(node->str), true);
5822
			File.copy(toDir.File(node->str).ToString(), true);
5824
		}
5823
		}
5825
 
5824
 
5826
		delete dirs;
5825
		delete dirs;
5827
	}
5826
	}
5828
 
5827
 
Line 5858... Line 5857...
5858
	Dir.RemoveDir("objects", false, true, 0);
5857
	Dir.RemoveDir("objects", false, true, 0);
5859
	Dir.RemoveDir("types", false, true, 0);
5858
	Dir.RemoveDir("types", false, true, 0);
5860
	Dir.RemoveDir("textures", false, true, 0);
5859
	Dir.RemoveDir("textures", false, true, 0);
5861
 
5860
 
5862
	// remove the plugin manager mod files
5861
	// remove the plugin manager mod files
5863
	if ( Dir.Exists("mods/PluginManager.cat") )
-
 
5864
		CFileIO(Dir.File("mods/PluginManager.cat")).Remove();
5862
	if ( Dir.Exists("mods/PluginManager.cat") )	CFileIO::Remove(Dir.File("mods/PluginManager.cat").ToString());
5865
	if ( Dir.Exists("mods/PluginManager.dat") )
-
 
5866
		CFileIO(Dir.File("mods/PluginManager.dat")).Remove();
5863
	if ( Dir.Exists("mods/PluginManager.dat") )	CFileIO::Remove(Dir.File("mods/PluginManager.dat").ToString());
5867
 
5864
 
5868
	return true;
5865
	return true;
5869
}
5866
}
5870
 
5867
 
5871
void CPackages::CreateDummies()
5868
void CPackages::CreateDummies()
Line 5958... Line 5955...
5958
				}
5955
				}
5959
 
5956
 
5960
				delete lines;
5957
				delete lines;
5961
			}
5958
			}
5962
 
5959
 
5963
			File.Remove();
5960
			File.remove();
5964
		}
5961
		}
5965
 
5962
 
5966
		// add the new entries for the ships
5963
		// add the new entries for the ships
5967
		for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
5964
		for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
5968
		{
5965
		{
Line 6040... Line 6037...
6040
		// write the file to disk
6037
		// write the file to disk
6041
		CFileIO WriteFile(m_sTempDir + "/dummies.txt");
6038
		CFileIO WriteFile(m_sTempDir + "/dummies.txt");
6042
		if ( WriteFile.WriteFile(&lines) )
6039
		if ( WriteFile.WriteFile(&lines) )
6043
		{
6040
		{
6044
			this->PackFile(&WriteFile, "types\\dummies.pck");
6041
			this->PackFile(&WriteFile, "types\\dummies.pck");
6045
			WriteFile.Remove();
6042
			WriteFile.remove();
6046
		}
6043
		}
6047
	}
6044
	}
6048
}
6045
}
6049
 
6046
 
6050
void CPackages::CreateCutData()
6047
void CPackages::CreateCutData()
Line 6102... Line 6099...
6102
				}
6099
				}
6103
 
6100
 
6104
				delete lines;
6101
				delete lines;
6105
			}
6102
			}
6106
 
6103
 
6107
			File.Remove();
6104
			File.remove();
6108
		}
6105
		}
6109
	}
6106
	}
6110
 
6107
 
6111
	for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
6108
	for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
6112
	{
6109
	{
Line 6136... Line 6133...
6136
	// write the file to disk
6133
	// write the file to disk
6137
	CFileIO WriteFile(m_sTempDir + "/CutData.txt");
6134
	CFileIO WriteFile(m_sTempDir + "/CutData.txt");
6138
	if ( WriteFile.WriteFile(&cutList) )
6135
	if ( WriteFile.WriteFile(&cutList) )
6139
	{
6136
	{
6140
		this->PackFile(&WriteFile, "types\\CutData.pck");
6137
		this->PackFile(&WriteFile, "types\\CutData.pck");
6141
		WriteFile.Remove();
6138
		WriteFile.remove();
6142
	}
6139
	}
6143
}
6140
}
6144
 
6141
 
6145
void CPackages::CreateAnimations()
6142
void CPackages::CreateAnimations()
6146
{
6143
{
Line 6182... Line 6179...
6182
				}
6179
				}
6183
 
6180
 
6184
				delete lines;
6181
				delete lines;
6185
			}
6182
			}
6186
 
6183
 
6187
			File.Remove();
6184
			File.remove();
6188
		}
6185
		}
6189
	}
6186
	}
6190
 
6187
 
6191
	CyStringList parsedAniList;
6188
	CyStringList parsedAniList;
6192
	CXspFile::ReadAnimations(&aniList, &parsedAniList, 0);
6189
	CXspFile::ReadAnimations(&aniList, &parsedAniList, 0);
Line 6287... Line 6284...
6287
	// write the file to disk
6284
	// write the file to disk
6288
	CFileIO WriteFile(m_sTempDir + "/Animations.txt");
6285
	CFileIO WriteFile(m_sTempDir + "/Animations.txt");
6289
	if ( WriteFile.WriteFile(&formatedAniList) )
6286
	if ( WriteFile.WriteFile(&formatedAniList) )
6290
	{
6287
	{
6291
		this->PackFile(&WriteFile, "types\\Animations.pck");
6288
		this->PackFile(&WriteFile, "types\\Animations.pck");
6292
		WriteFile.Remove();
6289
		WriteFile.remove();
6293
	}
6290
	}
6294
}
6291
}
6295
 
6292
 
6296
void CPackages::CreateBodies()
6293
void CPackages::CreateBodies()
6297
{
6294
{
Line 6361... Line 6358...
6361
					}
6358
					}
6362
				}
6359
				}
6363
 
6360
 
6364
				delete lines;
6361
				delete lines;
6365
			}
6362
			}
6366
			File.Remove();
6363
			File.remove();
6367
		}
6364
		}
6368
	}
6365
	}
6369
 
6366
 
6370
	// lets now add any new entries
6367
	// lets now add any new entries
6371
	for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
6368
	for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
Line 6434... Line 6431...
6434
	// write the file to disk
6431
	// write the file to disk
6435
	CFileIO WriteFile(m_sTempDir + "/Bodies.txt");
6432
	CFileIO WriteFile(m_sTempDir + "/Bodies.txt");
6436
	if ( WriteFile.WriteFile(&writeList) )
6433
	if ( WriteFile.WriteFile(&writeList) )
6437
	{
6434
	{
6438
		this->PackFile(&WriteFile, "types\\Bodies.pck");
6435
		this->PackFile(&WriteFile, "types\\Bodies.pck");
6439
		WriteFile.Remove();
6436
		WriteFile.remove();
6440
	}
6437
	}
6441
}
6438
}
6442
 
6439
 
6443
void CPackages::CreateCustomStarts()
6440
void CPackages::CreateCustomStarts()
6444
{
6441
{
Line 6477... Line 6474...
6477
				// create a maps files
6474
				// create a maps files
6478
				int e = this->ExtractGameFile(str->data + ".pck", m_sTempDir + "/" + str->data + ".pck");
6475
				int e = this->ExtractGameFile(str->data + ".pck", m_sTempDir + "/" + str->data + ".pck");
6479
				if ( e )
6476
				if ( e )
6480
				{
6477
				{
6481
					CFileIO File((e == -1) ? (str->data + ".pck") : (m_sTempDir + "/" + str->data + ".pck"));
6478
					CFileIO File((e == -1) ? (str->data + ".pck") : (m_sTempDir + "/" + str->data + ".pck"));
6482
					if ( File.Exists() )
6479
					if ( File.exists() )
6483
					{
6480
					{
6484
						File.Rename(m_sCurrentDir + "/" + dir + "/" + str->str + ".pck");
6481
						File.Rename(m_sCurrentDir + "/" + dir + "/" + str->str + ".pck");
6485
						this->AddCreatedFile(dir + "/" + str->str + ".pck");
6482
						this->AddCreatedFile(dir + "/" + str->str + ".pck");
6486
					}
6483
					}
6487
				}
6484
				}
Line 6592... Line 6589...
6592
				}
6589
				}
6593
 
6590
 
6594
				delete lines;
6591
				delete lines;
6595
			}
6592
			}
6596
 
6593
 
6597
			File.Remove();
6594
			File.remove();
6598
		}
6595
		}
6599
 
6596
 
6600
		// add the new entries for the ships
6597
		// add the new entries for the ships
6601
		for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
6598
		for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
6602
		{
6599
		{
Line 6697... Line 6694...
6697
		// write the file to disk
6694
		// write the file to disk
6698
		CFileIO WriteFile(m_sTempDir + "/Components.txt");
6695
		CFileIO WriteFile(m_sTempDir + "/Components.txt");
6699
		if ( WriteFile.WriteFile(&lines) )
6696
		if ( WriteFile.WriteFile(&lines) )
6700
		{
6697
		{
6701
			this->PackFile(&WriteFile, "types\\Components.pck");
6698
			this->PackFile(&WriteFile, "types\\Components.pck");
6702
			WriteFile.Remove();
6699
			WriteFile.remove();
6703
		}
6700
		}
6704
	}
6701
	}
6705
}
6702
}
6706
 
6703
 
6707
bool CPackages::ReadGlobals(CyStringList &globals)
6704
bool CPackages::ReadGlobals(CyStringList &globals)
6708
{
6705
{
6709
	int e = ExtractGameFile("types/Globals.pck", m_sTempDir);
6706
	int e = ExtractGameFile("types/Globals.pck", m_sTempDir);
6710
	if ( e )
6707
	if ( e )
6711
	{
6708
	{
6712
		CFileIO File(((e == -1) ? "." : m_sTempDir) + "/Globals.txt");
6709
		CFileIO File(((e == -1) ? "." : m_sTempDir) + "/Globals.txt");
6713
		if ( File.Exists() )
6710
		if ( File.exists() )
6714
		{
6711
		{
6715
			CyStringList *lines = File.ReadLinesStr();
6712
			CyStringList *lines = File.ReadLinesStr();
6716
			if ( lines )
6713
			if ( lines )
6717
			{
6714
			{
6718
				int entries = -1;
6715
				int entries = -1;
Line 6775... Line 6772...
6775
 
6772
 
6776
		CFileIO WriteFile(m_sTempDir + "/Globals.txt");
6773
		CFileIO WriteFile(m_sTempDir + "/Globals.txt");
6777
		if ( WriteFile.WriteFile(&writeList) )
6774
		if ( WriteFile.WriteFile(&writeList) )
6778
		{
6775
		{
6779
			this->PackFile(&WriteFile, "types/Globals.pck");
6776
			this->PackFile(&WriteFile, "types/Globals.pck");
6780
			WriteFile.Remove();
6777
			WriteFile.remove();
6781
		}
6778
		}
6782
	}
6779
	}
6783
}
6780
}
6784
 
6781
 
6785
void CPackages::CreateTShips()
6782
void CPackages::CreateTShips()
Line 6885... Line 6882...
6885
 
6882
 
6886
				delete lines;
6883
				delete lines;
6887
 
6884
 
6888
			}
6885
			}
6889
 
6886
 
6890
			File.Remove();
6887
			File.remove();
6891
 
6888
 
6892
			// assign the ship buffer
6889
			// assign the ship buffer
6893
			if ( !m_iShipBuffer )
6890
			if ( !m_iShipBuffer )
6894
				m_iShipBuffer = tshipsList.Count() + 15;
6891
				m_iShipBuffer = tshipsList.Count() + 15;
6895
			// there seems to be too many additional entries, we have no choise but to change the buffer
6892
			// there seems to be too many additional entries, we have no choise but to change the buffer
Line 6934... Line 6931...
6934
 
6931
 
6935
			CFileIO WriteFile(m_sTempDir + "/TShips.txt");
6932
			CFileIO WriteFile(m_sTempDir + "/TShips.txt");
6936
			if ( WriteFile.WriteFile(&tshipsList) )
6933
			if ( WriteFile.WriteFile(&tshipsList) )
6937
			{
6934
			{
6938
				this->PackFile(&WriteFile, "types/TShips.pck");
6935
				this->PackFile(&WriteFile, "types/TShips.pck");
6939
				WriteFile.Remove();
6936
				WriteFile.remove();
6940
			}
6937
			}
6941
		}
6938
		}
6942
	}
6939
	}
6943
 
6940
 
6944
}
6941
}
Line 6999... Line 6996...
6999
			if ( checkxml )
6996
			if ( checkxml )
7000
			{
6997
			{
7001
				int readmaxlines = 20;
6998
				int readmaxlines = 20;
7002
				bool isxml = false;
6999
				bool isxml = false;
7003
				do {
7000
				do {
7004
					CyString line = pckFile.ReadToEndLine(true);
7001
					CyString line = pckFile.readEndOfLine();
7005
					if ( line.IsIn("<language id=") )
7002
					if ( line.IsIn("<language id=") )
7006
					{
7003
					{
7007
						isxml = true;
7004
						isxml = true;
7008
						break;
7005
						break;
7009
					}
7006
					}
Line 7018... Line 7015...
7018
						break;
7015
						break;
7019
					}
7016
					}
7020
					--readmaxlines;
7017
					--readmaxlines;
7021
					if ( readmaxlines <= 0 )
7018
					if ( readmaxlines <= 0 )
7022
						break;
7019
						break;
7023
				} while (pckFile.IsOpened());
7020
				} while (pckFile.isOpened());
7024
 
7021
 
7025
				if ( pckFile.IsOpened() )
7022
				if ( pckFile.isOpened() )
7026
					pckFile.StopRead();
7023
					pckFile.StopRead();
7027
 
7024
 
7028
				if ( isxml )
7025
				if ( isxml )
7029
					pckFile.Rename(pckFile.ChangeFileExtension("xml"));
7026
					pckFile.Rename(pckFile.ChangeFileExtension("xml"));
7030
			}
7027
			}
Line 7044... Line 7041...
7044
		CCatFile catFile;
7041
		CCatFile catFile;
7045
		int error = catFile.Open(m_sCurrentDir + "/mods/PluginManager.cat", this->GetAddonDir(), CATREAD_CATDECRYPT, true);
7042
		int error = catFile.Open(m_sCurrentDir + "/mods/PluginManager.cat", this->GetAddonDir(), CATREAD_CATDECRYPT, true);
7046
		if ( error == CATERR_NONE || error == CATERR_CREATED )
7043
		if ( error == CATERR_NONE || error == CATERR_CREATED )
7047
		{
7044
		{
7048
			// it it wrote ok, remove the old ones
7045
			// it it wrote ok, remove the old ones
7049
			if ( !catFile.AppendFile(File->GetFullFilename(), filename, true, true) )
7046
			if ( !catFile.AppendFile(File->GetFullFilename().ToString(), filename.ToString(), true, true) )
7050
				return false;
7047
				return false;
7051
			return true;
7048
			return true;
7052
		}
7049
		}
7053
	}
7050
	}
7054
	else
7051
	else
Line 7132... Line 7129...
7132
				}
7129
				}
7133
 
7130
 
7134
				delete lines;
7131
				delete lines;
7135
			}
7132
			}
7136
 
7133
 
7137
			File.Remove();
7134
			File.remove();
7138
		}
7135
		}
7139
 
7136
 
7140
		// now add the new ones
7137
		// now add the new ones
7141
		for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
7138
		for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
7142
		{
7139
		{
Line 7187... Line 7184...
7187
 
7184
 
7188
		CFileIO WriteFile(m_sTempDir + "/TCockpits.txt");
7185
		CFileIO WriteFile(m_sTempDir + "/TCockpits.txt");
7189
		if ( WriteFile.WriteFile(cockpitList) )
7186
		if ( WriteFile.WriteFile(cockpitList) )
7190
		{
7187
		{
7191
			this->PackFile(&WriteFile, "types\\TCockpits.pck");
7188
			this->PackFile(&WriteFile, "types\\TCockpits.pck");
7192
			WriteFile.Remove();
7189
			WriteFile.remove();
7193
		}
7190
		}
7194
 
7191
 
7195
		// remove those entrys
7192
		// remove those entrys
7196
		cockpitList->PopFront();
7193
		cockpitList->PopFront();
7197
		cockpitList->PopFront();
7194
		cockpitList->PopFront();
Line 7219... Line 7216...
7219
}
7216
}
7220
 
7217
 
7221
CBaseFile *CPackages::LoadPackagerScript(CyString filename, int compression, CyString (*askFunc)(CyString), CyStringList *malformedLines, CyStringList *unknownCommands, CyStringList *variables)
7218
CBaseFile *CPackages::LoadPackagerScript(CyString filename, int compression, CyString (*askFunc)(CyString), CyStringList *malformedLines, CyStringList *unknownCommands, CyStringList *variables)
7222
{
7219
{
7223
	// check the file exists
7220
	// check the file exists
7224
	if ( !CFileIO(filename).Exists() )
7221
	if ( !CFileIO(filename).ExistsOld() )
7225
		return NULL;
7222
		return NULL;
7226
 
7223
 
7227
	// read all the lines
7224
	// read all the lines
7228
	CFileIO File(filename);
7225
	CFileIO File(filename);
7229
	std::vector<CyString> *lines = File.ReadLines();
7226
	std::vector<CyString> *lines = File.ReadLines();
Line 7470... Line 7467...
7470
 
7467
 
7471
	// write a file, then read the contents
7468
	// write a file, then read the contents
7472
	CFileIO File(dir + "/accessrightscheck.dat");
7469
	CFileIO File(dir + "/accessrightscheck.dat");
7473
 
7470
 
7474
	// check if file exists and remove it
7471
	// check if file exists and remove it
7475
	if ( File.Exists() )
7472
	if ( File.exists() )
7476
	{
7473
	{
7477
		// if we cant remove it, we dont have enough rights
7474
		// if we cant remove it, we dont have enough rights
7478
		if ( !File.Remove() )
7475
		if ( !File.remove() )
7479
			return false;
7476
			return false;
7480
 
7477
 
7481
		// if its still there, we dont have enough rights
7478
		// if its still there, we dont have enough rights
7482
		if ( File.Exists() )
7479
		if ( File.exists() )
7483
			return false;
7480
			return false;
7484
	}
7481
	}
7485
 
7482
 
7486
	// now create the file
7483
	// now create the file
7487
	if ( !File.WriteString("testing access rights") )
7484
	if ( !File.WriteString("testing access rights") )
7488
		return false;
7485
		return false;
7489
 
7486
 
7490
	// now check it exists
7487
	// now check it exists
7491
	if ( !File.Exists() )
7488
	if ( !File.exists() )
7492
		return false;
7489
		return false;
7493
 
7490
 
7494
	// now read the file for the correct contents
7491
	// now read the file for the correct contents
7495
	CyStringList *lines = File.ReadLinesStr();
7492
	CyStringList *lines = File.ReadLinesStr();
7496
	if ( !lines )
7493
	if ( !lines )
Line 7545... Line 7542...
7545
		deleteFile = true;
7542
		deleteFile = true;
7546
	}
7543
	}
7547
	else
7544
	else
7548
		File.Open(file);
7545
		File.Open(file);
7549
 
7546
 
7550
	if ( !File.Exists() )
7547
	if ( !File.exists() )
7551
		return false;
7548
		return false;
7552
 
7549
 
7553
	bool ret = false;
7550
	bool ret = false;
7554
	CyStringList *lines = File.ReadLinesStr();
7551
	CyStringList *lines = File.ReadLinesStr();
7555
	if ( lines )
7552
	if ( lines )
Line 7581... Line 7578...
7581
		delete lines;
7578
		delete lines;
7582
		ret = true;
7579
		ret = true;
7583
	}
7580
	}
7584
 
7581
 
7585
	if ( deleteFile )
7582
	if ( deleteFile )
7586
		File.Remove();
7583
		File.remove();
7587
 
7584
 
7588
	return ret;
7585
	return ret;
7589
}
7586
}
7590
 
7587
 
7591
CyString CPackages::ReadShipData(CyString file, CyString id)
7588
CyString CPackages::ReadShipData(CyString file, CyString id)
Line 7682... Line 7679...
7682
		deleteFile = true;
7679
		deleteFile = true;
7683
	}
7680
	}
7684
	else
7681
	else
7685
		File.Open(file);
7682
		File.Open(file);
7686
 
7683
 
7687
	if ( !File.Exists() )
7684
	if ( !File.exists() )
7688
		return false;
7685
		return false;
7689
 
7686
 
7690
	// open and read file
7687
	// open and read file
7691
	CyStringList *lines = File.ReadLinesStr();
7688
	CyStringList *lines = File.ReadLinesStr();
7692
	if ( !lines )
7689
	if ( !lines )
Line 7798... Line 7795...
7798
 
7795
 
7799
void CPackages::RemoveFailedFiles()
7796
void CPackages::RemoveFailedFiles()
7800
{
7797
{
7801
	for ( SStringList *str = m_lNonRemovedFiles.Head(); str; str = str->next )
7798
	for ( SStringList *str = m_lNonRemovedFiles.Head(); str; str = str->next )
7802
	{
7799
	{
7803
		if ( CFileIO(str->str).Remove() )
7800
		if ( CFileIO::Remove(str->str.ToString()) )
7804
			str->remove = true;
7801
			str->remove = true;
7805
	}
7802
	}
7806
 
7803
 
7807
	m_lNonRemovedFiles.RemoveMarked();
7804
	m_lNonRemovedFiles.RemoveMarked();
7808
}
7805
}
Line 8104... Line 8101...
8104
	}
8101
	}
8105
	
8102
	
8106
	for ( CListNode<C_File> *fNode = newFile->GetFileList()->Front(); fNode; fNode = fNode->next() )
8103
	for ( CListNode<C_File> *fNode = newFile->GetFileList()->Front(); fNode; fNode = fNode->next() )
8107
	{
8104
	{
8108
		C_File *f = fNode->Data();
8105
		C_File *f = fNode->Data();
8109
		CFileIO(f->GetFilePointer()).Remove();
8106
		CFileIO::Remove(f->GetFilePointer().ToString());
8110
		f->SetFullDir("");
8107
		f->SetFullDir("");
8111
	}
8108
	}
8112
 
8109
 
8113
	return count;
8110
	return count;
8114
}
8111
}
Line 8472... Line 8469...
8472
			error = true;
8469
			error = true;
8473
			break;
8470
			break;
8474
		}
8471
		}
8475
 
8472
 
8476
		CFileIO File(fileName);
8473
		CFileIO File(fileName);
8477
		if ( File.Exists() )
8474
		if ( File.exists() )
8478
		{
8475
		{
8479
			if ( fileName.Compare("pluginmanager.txt") )
8476
			if ( fileName.Compare("pluginmanager.txt") )
8480
				this->ReadArchiveData(File.GetFullFilename(), archive);
8477
				this->ReadArchiveData(File.GetFullFilename(), archive);
8481
			else
8478
			else
8482
			{
8479
			{
Line 8498... Line 8495...
8498
				else
8495
				else
8499
					f = archive->AddFile(CFileIO(fileName).GetFilename(), extradir, type);
8496
					f = archive->AddFile(CFileIO(fileName).GetFilename(), extradir, type);
8500
				f->ReadFromFile(File.GetFullFilename());
8497
				f->ReadFromFile(File.GetFullFilename());
8501
			}
8498
			}
8502
 
8499
 
8503
			File.Remove();
8500
			File.remove();
8504
		}
8501
		}
8505
	}
8502
	}
8506
 
8503
 
8507
	RARCloseArchive(hArcData);
8504
	RARCloseArchive(hArcData);
8508
 
8505
 
Line 8713... Line 8710...
8713
		bool exists = false;
8710
		bool exists = false;
8714
		if ( f->GetFilePointer().IsIn("::") ) {
8711
		if ( f->GetFilePointer().IsIn("::") ) {
8715
			CyString modFile = f->GetFilePointer().GetToken("::", 1, 1);
8712
			CyString modFile = f->GetFilePointer().GetToken("::", 1, 1);
8716
			CyString file = f->GetFilePointer().GetToken("::", 2, 2);
8713
			CyString file = f->GetFilePointer().GetToken("::", 2, 2);
8717
 
8714
 
8718
			if ( CFileIO(modFile).Exists() ) {
8715
			if ( CFileIO(modFile).ExistsOld() ) {
8719
				CCatFile catFile;
8716
				CCatFile catFile;
8720
				if ( catFile.Open(modFile, "", CATREAD_CATDECRYPT, false) == CATERR_NONE ) {
8717
				if ( catFile.Open(modFile, "", CATREAD_CATDECRYPT, false) == CATERR_NONE ) {
8721
					if ( catFile.FindData(file) )
8718
					if ( catFile.FindData(file) )
8722
						exists = true;
8719
						exists = true;
8723
				}
8720
				}
8724
			}
8721
			}
8725
		}
8722
		}
8726
		else {
8723
		else {
8727
			exists = CFileIO(f->GetFilePointer()).Exists();
8724
			exists = CFileIO(f->GetFilePointer()).ExistsOld();
8728
		}
8725
		}
8729
 
8726
 
8730
		if ( !exists )
8727
		if ( !exists )
8731
		{
8728
		{
8732
			++count;
8729
			++count;