Subversion Repositories spk

Rev

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

Rev 185 Rev 196
Line 136... Line 136...
136
			Utils::CStringList files;
136
			Utils::CStringList files;
137
			if (dir.dirList(files, Utils::String::Null(), "*.sav"))
137
			if (dir.dirList(files, Utils::String::Null(), "*.sav"))
138
			{
138
			{
139
				for (auto itr = files.begin(); itr != files.end(); ++itr)
139
				for (auto itr = files.begin(); itr != files.end(); ++itr)
140
				{
140
				{
141
					Utils::String f = dir.file((*itr)->str);
141
					Utils::WString f = dir.file((*itr)->str);
142
					CFileIO(f).copy(destDir1.file((*itr)->str));
142
					CFileIO(f).copy(destDir1.file((*itr)->str));
143
					CFileIO(f).copy(destDir2.file((*itr)->str));
143
					CFileIO(f).copy(destDir2.file((*itr)->str));
144
				}
144
				}
145
			}
145
			}
146
		}
146
		}
Line 730... Line 730...
730
Utils::String CPackages::logDirectory(const Utils::String &gameExe)
730
Utils::String CPackages::logDirectory(const Utils::String &gameExe)
731
{
731
{
732
	Utils::String logDir = m_sCurrentDir;
732
	Utils::String logDir = m_sCurrentDir;
733
	if ( m_iGameFlags & EXEFLAG_MYDOCLOG )
733
	if ( m_iGameFlags & EXEFLAG_MYDOCLOG )
734
	{
734
	{
735
		SGameExe *exe = m_gameExe.gameExe(CFileIO(gameExe).filename());
735
		SGameExe *exe = m_gameExe.gameExe(CFileIO(gameExe).filenameStr());
736
		if ( exe )
736
		if ( exe )
737
		{
737
		{
738
			if ( !exe->sMyDoc.empty() )
738
			if ( !exe->sMyDoc.empty() )
739
				logDir = m_sMyDoc + "/" + exe->sMyDoc;
739
				logDir = m_sMyDoc + "/" + exe->sMyDoc;
740
		}
740
		}
741
	}
741
	}
742
 
742
 
743
	return CFileIO(logDir).fullFilename();
743
	return CFileIO(logDir).fullFilenameStr();
744
}
744
}
745
 
745
 
746
Utils::String CPackages::saveDirectory()
746
Utils::String CPackages::saveDirectory()
747
{
747
{
748
	Utils::String logDir = this->logDirectory();
748
	Utils::String logDir = this->logDirectory();
Line 891... Line 891...
891
 
891
 
892
	CFileIO catFile(m_sCurrentDir + "/" + filename + ".cat");
892
	CFileIO catFile(m_sCurrentDir + "/" + filename + ".cat");
893
	if ( catFile.exists() && CFileIO::Exists(m_sCurrentDir + "/" + filename + ".dat"))
893
	if ( catFile.exists() && CFileIO::Exists(m_sCurrentDir + "/" + filename + ".dat"))
894
	{
894
	{
895
		CCatFile openFile;
895
		CCatFile openFile;
896
		if ( openFile.open(catFile.fullFilename(), this->getAddonDir(), CATREAD_CATDECRYPT, false) == CATERR_NONE )
896
		if ( openFile.open(catFile.fullFilenameStr(), this->getAddonDir(), CATREAD_CATDECRYPT, false) == CATERR_NONE )
897
		{
897
		{
898
//			if ( openFile.internaldatFilename().Compare("PlugMan_Fake.dat") ) return true;
898
//			if ( openFile.internaldatFilename().Compare("PlugMan_Fake.dat") ) return true;
899
			int count = 0;
899
			int count = 0;
900
			int noncount = 0;
900
			int noncount = 0;
901
 
901
 
902
			// check for some of the files
902
			// check for some of the files
903
			for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() ) {
903
			for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() ) {
904
				if ( node->Data()->fullDir().contains("::") ) {
904
				if ( node->Data()->fullDir().contains("::") ) {
905
					if (CFileIO(node->Data()->fullDir().token("::", 1)).filename().Compare("PlugMan_Fake.cat") ) {
905
					if (CFileIO(node->Data()->fullDir().token("::", 1)).filename().Compare(L"PlugMan_Fake.cat") ) {
906
						Utils::String filename = node->Data()->filePointer().token("::", 2);
906
						Utils::String filename = node->Data()->filePointer().token("::", 2);
907
						filename = filename.findReplace("/", "\\");
907
						filename = filename.findReplace("/", "\\");
908
						if ( openFile.findData(filename) )
908
						if ( openFile.findData(filename) )
909
							++count;
909
							++count;
910
						else
910
						else
Line 926... Line 926...
926
	// both the cat file and dat file exists, lets open it
926
	// both the cat file and dat file exists, lets open it
927
	CFileIO catFile(m_sCurrentDir + "/" + filename + ".cat");
927
	CFileIO catFile(m_sCurrentDir + "/" + filename + ".cat");
928
	if ( catFile.exists() && CFileIO::Exists(m_sCurrentDir + "/" + filename + ".dat"))
928
	if ( catFile.exists() && CFileIO::Exists(m_sCurrentDir + "/" + filename + ".dat"))
929
	{
929
	{
930
		CCatFile openFile;
930
		CCatFile openFile;
931
		if ( openFile.open(catFile.fullFilename(), this->getAddonDir(), CATREAD_CATDECRYPT, false) == CATERR_NONE )
931
		if ( openFile.open(catFile.fullFilenameStr(), this->getAddonDir(), CATREAD_CATDECRYPT, false) == CATERR_NONE )
932
		{
932
		{
933
			if ( openFile.findData("PlugMan\\TFake.pck") )
933
			if ( openFile.findData("PlugMan\\TFake.pck") )
934
				return true;
934
				return true;
935
			if ( openFile.findData("pluginmanagerfake.pck") )
935
			if ( openFile.findData("pluginmanagerfake.pck") )
936
				return true;
936
				return true;
Line 1271... Line 1271...
1271
		case SPKFILE_OLD:
1271
		case SPKFILE_OLD:
1272
			*error = INSTALLERR_OLD;
1272
			*error = INSTALLERR_OLD;
1273
			return NULL;
1273
			return NULL;
1274
		case SPKFILE_INVALID:
1274
		case SPKFILE_INVALID:
1275
			// convert xsp
1275
			// convert xsp
1276
			if ( CFileIO(file).isFileExtension("xsp") )
1276
			if ( CFileIO(file).isFileExtension(L"xsp") )
1277
			{
1277
			{
1278
				installFile = new CXspFile();
1278
				installFile = new CXspFile();
1279
				if ( !((CXspFile *)installFile)->ConvertOld(file) )
1279
				if ( !((CXspFile *)installFile)->ConvertOld(file) )
1280
				{
1280
				{
1281
					delete installFile;
1281
					delete installFile;
Line 4186... Line 4186...
4186
		int current = findNextTextFile();
4186
		int current = findNextTextFile();
4187
		if ( current < f->textFileID() )
4187
		if ( current < f->textFileID() )
4188
		{
4188
		{
4189
			CFileIO moveFile(f->filePointer());
4189
			CFileIO moveFile(f->filePointer());
4190
	
4190
	
4191
			Utils::String newName = SPK::FormatTextName(current, m_iLanguage, (m_iGameFlags & EXEFLAG_TCTEXT)) + "." + moveFile.extension();
4191
			Utils::String newName = SPK::FormatTextName(current, m_iLanguage, (m_iGameFlags & EXEFLAG_TCTEXT)) + "." + moveFile.extension().toString();
4192
			if ( moveFile.Rename(m_sCurrentDir + "/t/" + newName) )
4192
			if ( moveFile.Rename(m_sCurrentDir + "/t/" + newName) )
4193
			{
4193
			{
4194
				this->addLogEntry(SPKINSTALL_AUTOTEXT, f->name() + "~" + newName, errors);
4194
				this->addLogEntry(SPKINSTALL_AUTOTEXT, f->name() + "~" + newName, errors);
4195
				f->setName(newName);
4195
				f->setName(newName);
4196
			}
4196
			}
Line 4901... Line 4901...
4901
 
4901
 
4902
	if ( file->filePointer().contains("::")) {
4902
	if ( file->filePointer().contains("::")) {
4903
		CFileIO CatFile(file->filePointer().token("::", 1));
4903
		CFileIO CatFile(file->filePointer().token("::", 1));
4904
		if ( CatFile.exists() ) {
4904
		if ( CatFile.exists() ) {
4905
			CCatFile cat;
4905
			CCatFile cat;
4906
			if ( cat.open(CatFile.fullFilename(), this->getAddonDir(), CATREAD_DAT, false) == CATERR_NONE ) {
4906
			if ( cat.open(CatFile.fullFilenameStr(), this->getAddonDir(), CATREAD_DAT, false) == CATERR_NONE ) {
4907
				Utils::String fileName = file->filePointer().token("::", 2);
4907
				Utils::String fileName = file->filePointer().token("::", 2);
4908
				if ( cat.findData(fileName) ) {
4908
				if ( cat.findData(fileName) ) {
4909
					if ( cat.removeFile(fileName) ) {
4909
					if ( cat.removeFile(fileName) ) {
4910
						this->addLogEntry(SPKINSTALL_DELETEFILE, remFileStr, errors);
4910
						this->addLogEntry(SPKINSTALL_DELETEFILE, remFileStr, errors);
4911
					}
4911
					}
Line 5027... Line 5027...
5027
	int num = 0;
5027
	int num = 0;
5028
	for ( CListNode<CBaseFile> *node = m_lPackages.Front(); node; node = node->next() )
5028
	for ( CListNode<CBaseFile> *node = m_lPackages.Front(); node; node = node->next() )
5029
		node->Data()->SetNum(num++);
5029
		node->Data()->SetNum(num++);
5030
}
5030
}
5031
 
5031
 
5032
Utils::String CPackages::findDataDir(const Utils::String &dir, const Utils::String &file)
5032
Utils::WString CPackages::findDataDir(const Utils::WString &dir, const Utils::WString &file)
5033
{
5033
{
5034
	CDirIO Dir(dir);
5034
	CDirIO Dir(dir);
5035
 
5035
 
5036
	// data files could be in 4 places depending on what program is used, check for all of these
5036
	// data files could be in 4 places depending on what program is used, check for all of these
5037
	if (Dir.exists(file))
5037
	if (Dir.exists(file))
5038
		return Dir.file(file);
5038
		return Dir.file(file);
5039
	else if (Dir.exists("Data/" + file))
5039
	else if (Dir.exists(L"Data/" + file))
5040
		return Dir.file("Data/" + file);
5040
		return Dir.file(L"Data/" + file);
5041
	else if (Dir.exists("../" + file))
5041
	else if (Dir.exists(L"../" + file))
5042
		return Dir.file("../" + file);
5042
		return Dir.file(L"../" + file);
5043
	else if (Dir.exists("../Data/" + file))
5043
	else if (Dir.exists(L"../Data/" + file))
5044
		return Dir.file("../Data/" + file);
5044
		return Dir.file(L"../Data/" + file);
5045
 
5045
 
5046
	return Utils::String::Null();
5046
	return Utils::WString::Null();
5047
}
5047
}
5048
 
5048
 
5049
void CPackages::startup(const Utils::String &dir, const Utils::String &tempDir, const Utils::String &myDoc)
5049
void CPackages::startup(const Utils::String &dir, const Utils::String &tempDir, const Utils::String &myDoc)
5050
{
5050
{
5051
	this->setTempDirectory(tempDir);
5051
	this->setTempDirectory(tempDir);
5052
	this->setMyDocuments(myDoc);
5052
	this->setMyDocuments(myDoc);
5053
 
5053
 
5054
	// need to read the game exe versions
5054
	// need to read the game exe versions
5055
	m_gameExe.Reset();
5055
	m_gameExe.Reset();
5056
 
5056
 
5057
	Utils::String exeFile = this->findDataDir(dir, "exe");
5057
	Utils::WString exeFile = this->findDataDir(dir, L"exe");
5058
 
5058
 
5059
	// if file exists, read it, otherwise, just add
5059
	// if file exists, read it, otherwise, just add
5060
	if (!exeFile.empty() && CFileIO::Exists(exeFile))
5060
	if (!exeFile.empty() && CFileIO::Exists(exeFile))
5061
		m_gameExe.ReadFile(exeFile);
5061
		m_gameExe.ReadFile(exeFile.toString());
5062
	else
5062
	else
5063
	{
5063
	{
5064
		m_gameExe.ParseExe("x2.exe|0:5:NOSAVESUBDIR:HKCU/Software/EgoSoftware/X2/ModName:X2 The Threat:!GAMEDIR!:2:1604608!2150400:1.4 Artifical Life:1974272:1.5 Uplink");
5064
		m_gameExe.ParseExe("x2.exe|0:5:NOSAVESUBDIR:HKCU/Software/EgoSoftware/X2/ModName:X2 The Threat:!GAMEDIR!:2:1604608!2150400:1.4 Artifical Life:1974272:1.5 Uplink");
5065
		m_gameExe.ParseExe("x3.exe|30:5:0:HKCU/Software/Egosoft/X3/ModName:X3 Reunion:Egosoft/X3:2:2347008:2.0 Bala Gi:2367488!2375680:2.5 Uplink");
5065
		m_gameExe.ParseExe("x3.exe|30:5:0:HKCU/Software/Egosoft/X3/ModName:X3 Reunion:Egosoft/X3:2:2347008:2.0 Bala Gi:2367488!2375680:2.5 Uplink");
5066
		m_gameExe.ParseExe("x3tc.exe|35:5:NO_XOR|TC_TEXT|MYDOCLOG:HKCU/Software/Egosoft/X3TC/ModName:X3 Terran Conflict:Egosoft/X3TC:3:1933464!1933520:2.0 Aldrin Expansion:-1:2.5 A New Home (Superbox):-1:3.0 Balance of Power");
5066
		m_gameExe.ParseExe("x3tc.exe|35:5:NO_XOR|TC_TEXT|MYDOCLOG:HKCU/Software/Egosoft/X3TC/ModName:X3 Terran Conflict:Egosoft/X3TC:3:1933464!1933520:2.0 Aldrin Expansion:-1:2.5 A New Home (Superbox):-1:3.0 Balance of Power");
Line 5754... Line 5754...
5754
		default: return 0;
5754
		default: return 0;
5755
	}
5755
	}
5756
}
5756
}
5757
 
5757
 
5758
void CPackages::createPluginManagerOpenText()
5758
void CPackages::createPluginManagerOpenText()
5759
{
5759
{
5760
	int gameNumber = _gameTextNumber();
5760
	int gameNumber = _gameTextNumber();
5761
 
5761
 
5762
	int lang = m_iLanguage;
5762
	int lang = m_iLanguage;
5763
	if ( !lang || lang < 0 )
5763
	if ( !lang || lang < 0 )
5764
		lang = 44;
5764
		lang = 44;
5765
 
5765
 
5766
	CDirIO Dir(m_sCurrentDir);
5766
	CDirIO Dir(m_sCurrentDir);
5767
	if ( !Dir.exists("t") )
5767
	if ( !Dir.exists("t") )
5768
		Dir.create("t");
5768
		Dir.create("t");
5769
 
5769
 
5770
	Utils::String filename = SPK::FormatTextName(PMTEXTFILE, lang, (m_iGameFlags & EXEFLAG_TCTEXT));
5770
	Utils::String filename = SPK::FormatTextName(PMTEXTFILE, lang, (m_iGameFlags & EXEFLAG_TCTEXT));
5771
	CFileIO textFile(m_sCurrentDir + "/t/" + filename + ".xml");
5771
	CFileIO textFile(m_sCurrentDir + "/t/" + filename + ".xml");
5772
 
5772
 
5773
	std::vector<Utils::String> writeData;
5773
	std::vector<Utils::String> writeData;
5774
 
5774
 
5775
	writeData.push_back("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
5775
	writeData.push_back("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
5776
	writeData.push_back("<language id=\"" + Utils::String::Number(lang) + "\">");
5776
	writeData.push_back("<language id=\"" + Utils::String::Number(lang) + "\">");
5777
 
5777
 
5778
	if ( !gameNumber )
5778
	if ( !gameNumber )
5779
		writeData.push_back("	<page id=\"" + Utils::String::Number(PMTEXTFILE) + "\" title=\"Plugin Manager Text File\" descr=\"Contains text used for the plugin manager, packages, settings, wares, ship, etc\">");
5779
		writeData.push_back("	<page id=\"" + Utils::String::Number(PMTEXTFILE) + "\" title=\"Plugin Manager Text File\" descr=\"Contains text used for the plugin manager, packages, settings, wares, ship, etc\">");
5780
	else
5780
	else
5781
		writeData.push_back("	<page id=\"" + (long)gameNumber + Utils::String::PadNumber(PMTEXTFILE, 4) + "\" title=\"Plugin Manager Text File\" descr=\"Contains text used for the plugin manager, packages, settings, wares, ship, etc\">");
5781
		writeData.push_back("	<page id=\"" + (long)gameNumber + Utils::String::PadNumber(PMTEXTFILE, 4) + "\" title=\"Plugin Manager Text File\" descr=\"Contains text used for the plugin manager, packages, settings, wares, ship, etc\">");
5782
 
5782
 
5783
	writeData.push_back("		<t id=\"99998\">[author]Plugin Manager[/author]It appears the plugin manager hasn't been closed properly.  Make sure its closed before running the game otherwise things may not work correctly</t>");
5783
	writeData.push_back("		<t id=\"99998\">[author]Plugin Manager[/author]It appears the plugin manager hasn't been closed properly.  Make sure its closed before running the game otherwise things may not work correctly</t>");
Line 5796... Line 5796...
5796
		unsigned char *pckData = PCKData((unsigned char *)fileData, fileSize, &newFileSize, true);
5796
		unsigned char *pckData = PCKData((unsigned char *)fileData, fileSize, &newFileSize, true);
5797
		if ( pckData )
5797
		if ( pckData )
5798
		{
5798
		{
5799
			CFileIO pckFile(m_sCurrentDir + "/t/" + filename + ".pck");
5799
			CFileIO pckFile(m_sCurrentDir + "/t/" + filename + ".pck");
5800
			pckFile.WriteData((char *)pckData, newFileSize);
5800
			pckFile.WriteData((char *)pckData, newFileSize);
5801
			this->addCreatedFile(pckFile.fullFilename());
5801
			this->addCreatedFile(pckFile.fullFilenameStr());
5802
		}
5802
		}
5803
	}
5803
	}
5804
	textFile.remove();
5804
	textFile.remove();
5805
}
5805
}
5806
 
5806
 
Line 6063... Line 6063...
6063
		unsigned char *pckData = PCKData((unsigned char *)fileData, fileSize, &newFileSize, true);
6063
		unsigned char *pckData = PCKData((unsigned char *)fileData, fileSize, &newFileSize, true);
6064
		if ( pckData )
6064
		if ( pckData )
6065
		{
6065
		{
6066
			CFileIO pckFile(m_sCurrentDir + "/t/" + filename + ".pck");
6066
			CFileIO pckFile(m_sCurrentDir + "/t/" + filename + ".pck");
6067
			pckFile.WriteData((char *)pckData, newFileSize);
6067
			pckFile.WriteData((char *)pckData, newFileSize);
6068
			this->addCreatedFile(pckFile.fullFilename());
6068
			this->addCreatedFile(pckFile.fullFilenameStr());
6069
		}
6069
		}
6070
	}
6070
	}
6071
	textFile.remove();
6071
	textFile.remove();
6072
}
6072
}
6073
 
6073
 
Line 6107... Line 6107...
6107
			gameSaveDir.create(dir);
6107
			gameSaveDir.create(dir);
6108
		gameSaveDir.cd(dir);
6108
		gameSaveDir.cd(dir);
6109
 
6109
 
6110
		// backup the saves
6110
		// backup the saves
6111
		Utils::CStringList files;
6111
		Utils::CStringList files;
6112
		if(saveDir.dirList(files, Utils::String::Null(), "*.sav"))
6112
		if(saveDir.dirList(files, Utils::String::Null(), L"*.sav"))
6113
		{
6113
		{
6114
			for(auto itr = files.begin(); itr != files.end(); ++itr)
6114
			for(auto itr = files.begin(); itr != files.end(); ++itr)
6115
			{
6115
			{
6116
				CFileIO File(saveDir.file((*itr)->str));
6116
				CFileIO File(saveDir.file((*itr)->str));
6117
				if (!File.isFileExtension("sav"))
6117
				if (!File.isFileExtension(L"sav"))
6118
					continue;
6118
					continue;
6119
				// remove the file if already exists
6119
				// remove the file if already exists
6120
				if (gameSaveDir.exists((*itr)->str))
6120
				if (gameSaveDir.exists((*itr)->str))
6121
					CFileIO::Remove(gameSaveDir.file((*itr)->str));
6121
					CFileIO::Remove(gameSaveDir.file((*itr)->str));
6122
 
6122
 
Line 6504... Line 6504...
6504
	int e = extractGameFile("types/Animations.pck", m_sTempDir + "/Animations.txt");
6504
	int e = extractGameFile("types/Animations.pck", m_sTempDir + "/Animations.txt");
6505
	if ( e )
6505
	if ( e )
6506
	{
6506
	{
6507
		CFileIO File;
6507
		CFileIO File;
6508
		if ( File.open((e == -1) ? "Animations.txt" : m_sTempDir + "/Animations.txt") )
6508
		if ( File.open((e == -1) ? "Animations.txt" : m_sTempDir + "/Animations.txt") )
6509
		{
6509
		{
6510
			std::vector<Utils::String> *lines = File.readLines();
6510
			std::vector<Utils::String> *lines = File.readLines();
6511
			if ( lines )
6511
			if ( lines )
6512
			{
6512
			{
6513
				for ( int j = 0; j < (int)lines->size(); j++ )
6513
				for ( int j = 0; j < (int)lines->size(); j++ )
6514
				{
6514
				{
6515
					Utils::String line(lines->at(j));
6515
					Utils::String line(lines->at(j));
6516
					aniList.pushBack(line);
6516
					aniList.pushBack(line);
6517
				}
6517
				}
Line 6802... Line 6802...
6802
		createFiles.pushBack(name, "types/Jobs");
6802
		createFiles.pushBack(name, "types/Jobs");
6803
		createFiles.pushBack(name, "types/JobWings");
6803
		createFiles.pushBack(name, "types/JobWings");
6804
 
6804
 
6805
		for(auto itr = createFiles.begin(); itr != createFiles.end(); itr++)
6805
		for(auto itr = createFiles.begin(); itr != createFiles.end(); itr++)
6806
		{
6806
		{
6807
			Utils::String dir = CFileIO((*itr)->data).dir();
6807
			Utils::WString dir = CFileIO((*itr)->data).dir();
6808
			FileType type = FileType::FILETYPE_EXTRA;
6808
			FileType type = FileType::FILETYPE_EXTRA;
6809
			if ( dir.Compare("maps") )
6809
			if ( dir.Compare(L"maps") )
6810
				type = FileType::FILETYPE_MAP;
6810
				type = FileType::FILETYPE_MAP;
6811
 
6811
 
6812
			if ( !p->findFile((*itr)->str + ".xml", type) && !p->findFile((*itr)->str + ".pck", type))
6812
			if ( !p->findFile((*itr)->str + ".xml", type) && !p->findFile((*itr)->str + ".pck", type))
6813
			{
6813
			{
6814
				// create a maps files
6814
				// create a maps files
Line 6816... Line 6816...
6816
				if ( e )
6816
				if ( e )
6817
				{
6817
				{
6818
					CFileIO File((e == -1) ? ((*itr)->data + ".pck") : (m_sTempDir + "/" + (*itr)->data + ".pck"));
6818
					CFileIO File((e == -1) ? ((*itr)->data + ".pck") : (m_sTempDir + "/" + (*itr)->data + ".pck"));
6819
					if ( File.exists() )
6819
					if ( File.exists() )
6820
					{
6820
					{
6821
						File.Rename(m_sCurrentDir + ";/&quot; + dir + "/"; + (*itr)->str + ".pck");
6821
						File.Rename(m_sCurrentDir.toWString() + L"/" + dir + L";/&quot; + (*itr)->str.toWString() + L".pck");
6822
						this->addCreatedFile(dir + "/" + (*itr)->str + ".pck");
6822
						this->addCreatedFile(dir.toString() + "/" + (*itr)->str + ".pck");
6823
					}
6823
					}
6824
				}
6824
				}
6825
			}
6825
			}
6826
		}
6826
		}
6827
	}
6827
	}
Line 7405... Line 7405...
7405
	{
7405
	{
7406
		size_t newFileSize;
7406
		size_t newFileSize;
7407
		unsigned char *pckData = PCKData((unsigned char *)fileData, fileSize, &newFileSize, true);
7407
		unsigned char *pckData = PCKData((unsigned char *)fileData, fileSize, &newFileSize, true);
7408
		if ( pckData )
7408
		if ( pckData )
7409
		{
7409
		{
7410
			Utils::String ext = "pck";
7410
			Utils::WString ext = L"pck";
7411
			if ( File.isFileExtension("bob") )
7411
			if ( File.isFileExtension(L"bob") )
7412
				ext = "pbb";
7412
				ext = L"pbb";
7413
			else if ( File.isFileExtension("bod") )
7413
			else if ( File.isFileExtension(L"bod") )
7414
				ext = "pbd";
7414
				ext = L"pbd";
7415
			CFileIO pckFile(File.changeFileExtension(ext));
7415
			CFileIO pckFile(File.changeFileExtension(ext));
7416
			if ( !CDirIO(pckFile.dir()).exists() )
7416
			if ( !CDirIO(pckFile.dir()).exists() )
7417
				CDirIO(pckFile.dir()).create();
7417
				CDirIO(pckFile.dir()).create();
7418
			pckFile.WriteData((char *)pckData, newFileSize);
7418
			pckFile.WriteData((char *)pckData, newFileSize);
7419
			return true;
7419
			return true;
Line 7437... Line 7437...
7437
		if ( !pckData )
7437
		if ( !pckData )
7438
			pckData = UnPCKData((unsigned char *)fileData, fileSize, &newFileSize, true);
7438
			pckData = UnPCKData((unsigned char *)fileData, fileSize, &newFileSize, true);
7439
 
7439
 
7440
		if ( pckData )
7440
		if ( pckData )
7441
		{
7441
		{
7442
			Utils::String ext = "txt";
7442
			Utils::WString ext = L"txt";
7443
			if ( File.isFileExtension("pbb") )
7443
			if ( File.isFileExtension(L"pbb") )
7444
				ext = "bob";
7444
				ext = L"bob";
7445
			else if ( File.isFileExtension("pbd") )
7445
			else if ( File.isFileExtension(L"pbd") )
7446
				ext = "bod";
7446
				ext = L"bod";
7447
			CFileIO pckFile(File.changeFileExtension(ext));
7447
			CFileIO pckFile(File.changeFileExtension(ext));
7448
			if ( !CDirIO(pckFile.dir()).exists() )
7448
			if ( !CDirIO(pckFile.dir()).exists() )
7449
				CDirIO(pckFile.dir()).create();
7449
				CDirIO(pckFile.dir()).create();
7450
			pckFile.WriteData((char *)pckData, newFileSize);
7450
			pckFile.WriteData((char *)pckData, newFileSize);
7451
 
7451
 
Line 7478... Line 7478...
7478
 
7478
 
7479
				if ( pckFile.isOpened() )
7479
				if ( pckFile.isOpened() )
7480
					pckFile.close();
7480
					pckFile.close();
7481
 
7481
 
7482
				if ( isxml )
7482
				if ( isxml )
7483
					pckFile.Rename(pckFile.changeFileExtension("xml"));
7483
					pckFile.Rename(pckFile.changeFileExtension(L"xml"));
7484
			}
7484
			}
7485
 
7485
 
7486
			return true;
7486
			return true;
7487
		}
7487
		}
7488
	}
7488
	}
Line 7498... Line 7498...
7498
		CCatFile catFile;
7498
		CCatFile catFile;
7499
		int error = catFile.open(m_sCurrentDir + "/mods/PluginManager.cat", this->getAddonDir(), CATREAD_CATDECRYPT, true);
7499
		int error = catFile.open(m_sCurrentDir + "/mods/PluginManager.cat", this->getAddonDir(), CATREAD_CATDECRYPT, true);
7500
		if ( error == CATERR_NONE || error == CATERR_CREATED )
7500
		if ( error == CATERR_NONE || error == CATERR_CREATED )
7501
		{
7501
		{
7502
			// it it wrote ok, remove the old ones
7502
			// it it wrote ok, remove the old ones
7503
			if ( !catFile.appendFile(File->fullFilename(), filename, true, true) )
7503
			if ( !catFile.appendFile(File->fullFilenameStr(), filename, true, true) )
7504
				return false;
7504
				return false;
7505
			return true;
7505
			return true;
7506
		}
7506
		}
7507
	}
7507
	}
7508
	else
7508
	else
Line 7521... Line 7521...
7521
//					filename = this->GetAddonDir() + "/" + filename;
7521
//					filename = this->GetAddonDir() + "/" + filename;
7522
				CFileIO pckFile(m_sCurrentDir + "/" + filename);
7522
				CFileIO pckFile(m_sCurrentDir + "/" + filename);
7523
				if ( !CDirIO(pckFile.dir()).exists() )
7523
				if ( !CDirIO(pckFile.dir()).exists() )
7524
					CDirIO(pckFile.dir()).create();
7524
					CDirIO(pckFile.dir()).create();
7525
				pckFile.WriteData((char *)pckData, newFileSize);
7525
				pckFile.WriteData((char *)pckData, newFileSize);
7526
				const_cast<CPackages *>(this)->addCreatedFile(pckFile.fullFilename());
7526
				const_cast<CPackages *>(this)->addCreatedFile(pckFile.fullFilenameStr());
7527
				return true;
7527
				return true;
7528
			}
7528
			}
7529
		}
7529
		}
7530
	}
7530
	}
7531
 
7531
 
Line 7855... Line 7855...
7855
			}
7855
			}
7856
 
7856
 
7857
			// current path
7857
			// current path
7858
			if ( rest.isin("$PATH") )
7858
			if ( rest.isin("$PATH") )
7859
			{
7859
			{
7860
				Utils::String currentDir = CFileIO(filename).dir();
7860
				Utils::WString currentDir = CFileIO(filename).dir();
7861
				if ( !currentDir.empty() )
7861
				if ( !currentDir.empty() )
7862
					rest = rest.findReplace("$PATH", currentDir);
7862
					rest = rest.findReplace("$PATH", currentDir.toString());
7863
			}
7863
			}
7864
 
7864
 
7865
			// now parse the rest of the values
7865
			// now parse the rest of the values
7866
			if ( cmd.Compare("FtpUpload") )
7866
			if ( cmd.Compare("FtpUpload") )
7867
				ftpaddr = rest.token(" ", 1) + ":" + rest.token(" ", 2);
7867
				ftpaddr = rest.token(" ", 1) + ":" + rest.token(" ", 2);
Line 7970... Line 7970...
7970
}
7970
}
7971
int CPackages::findPackageDirectories(CLinkList<CBaseFile> &packages, const Utils::String &dir)
7971
int CPackages::findPackageDirectories(CLinkList<CBaseFile> &packages, const Utils::String &dir)
7972
{
7972
{
7973
	CDirIO Dir(dir);
7973
	CDirIO Dir(dir);
7974
	int count = 0;
7974
	int count = 0;
7975
	Utils::CStringList files;
7975
	Utils::WStringList files;
7976
	if (Dir.dirList(files))
7976
	if (Dir.dirList(files))
7977
	{
7977
	{
7978
		for (auto itr = files.begin(); itr != files.end(); itr++)
7978
		for (auto itr = files.begin(); itr != files.end(); itr++)
7979
		{
7979
		{
7980
			Utils::String d = Dir.file((*itr)->str);
7980
			Utils::WString d = Dir.file((*itr)->str);
7981
			if (CDirIO(d).isDir())
7981
			if (CDirIO(d).isDir())
7982
				count += findPackageDirectories(packages, d);
7982
				count += findPackageDirectories(packages, d.toString());
7983
		}
7983
		}
7984
	}
7984
	}
7985
 
7985
 
7986
	count += findPackageFiles(packages, dir);
7986
	count += findPackageFiles(packages, dir);
7987
	return count;
7987
	return count;
Line 7990... Line 7990...
7990
{
7990
{
7991
	CDirIO Dir(dir);
7991
	CDirIO Dir(dir);
7992
	int count = 0;
7992
	int count = 0;
7993
	for (int type = 0; type < 2; type++)
7993
	for (int type = 0; type < 2; type++)
7994
	{
7994
	{
7995
		Utils::CStringList files;
7995
		Utils::WStringList files;
7996
		if (type == 0)
7996
		if (type == 0)
7997
			Dir.dirList(files, Utils::String::Null(), "*.spk");
7997
			Dir.dirList(files, Utils::WString::Null(), L"*.spk");
7998
		else if(type == 1)
7998
		else if(type == 1)
7999
			Dir.dirList(files, Utils::String::Null(), "*.xsp");
7999
			Dir.dirList(files, Utils::WString::Null(), L"*.xsp");
8000
		else
8000
		else
8001
			break;
8001
			break;
8002
			
8002
			
8003
		for(auto itr = files.begin(); itr != files.end(); itr++)
8003
		for(auto itr = files.begin(); itr != files.end(); itr++)
8004
		{
8004
		{
8005
			Utils::String f = Dir.file((*itr)->str);
8005
			Utils::String f = Dir.file((*itr)->str).toString();
8006
			int error = 0;
8006
			int error = 0;
8007
			CBaseFile *p = this->openPackage(f, &error, 0, SPKREAD_NODATA, READFLAG_NOUNCOMPRESS);
8007
			CBaseFile *p = this->openPackage(f, &error, 0, SPKREAD_NODATA, READFLAG_NOUNCOMPRESS);
8008
			if (!p)
8008
			if (!p)
8009
				continue;
8009
				continue;
8010
			if (p->IsMod() || this->findSpkPackage(p->name(), p->author()))
8010
			if (p->IsMod() || this->findSpkPackage(p->name(), p->author()))
Line 8173... Line 8173...
8173
{
8173
{
8174
	CFileIO File;
8174
	CFileIO File;
8175
	bool deleteFile = false;
8175
	bool deleteFile = false;
8176
 
8176
 
8177
	// load from cat file
8177
	// load from cat file
8178
	if (CFileIO(file).isFileExtension("cat"))
8178
	if (CFileIO(file).isFileExtension(L"cat"))
8179
	{
8179
	{
8180
		CCatFile cat;
8180
		CCatFile cat;
8181
		if (cat.open(file, this->getAddonDir(), CATREAD_CATDECRYPT, false) != CATERR_NONE)
8181
		if (cat.open(file, this->getAddonDir(), CATREAD_CATDECRYPT, false) != CATERR_NONE)
8182
			return false;
8182
			return false;
8183
 
8183
 
Line 8186... Line 8186...
8186
 
8186
 
8187
		File.open(m_sTempDir + "/tships.txt");
8187
		File.open(m_sTempDir + "/tships.txt");
8188
		deleteFile = true;
8188
		deleteFile = true;
8189
	}
8189
	}
8190
	// otherwise its a normal file
8190
	// otherwise its a normal file
8191
	else if (CFileIO(file).isFileExtension("pck"))
8191
	else if (CFileIO(file).isFileExtension(L"pck"))
8192
	{
8192
	{
8193
		C_File f(file);
8193
		C_File f(file);
8194
		if (!f.ReadFromFile())
8194
		if (!f.ReadFromFile())
8195
			return false;
8195
			return false;
8196
		f.UnPCKFile();
8196
		f.UnPCKFile();
Line 8264... Line 8264...
8264
{
8264
{
8265
	CFileIO File;
8265
	CFileIO File;
8266
	bool deleteFile = false;
8266
	bool deleteFile = false;
8267
 
8267
 
8268
	// read all text files from mod
8268
	// read all text files from mod
8269
	if ( CFileIO(file).isFileExtension("cat") )
8269
	if ( CFileIO(file).isFileExtension(L"cat") )
8270
	{
8270
	{
8271
		bool done = false;
8271
		bool done = false;
8272
 
8272
 
8273
		CCatFile cat;
8273
		CCatFile cat;
8274
		if ( cat.open(file, this->getAddonDir(), CATREAD_CATDECRYPT, false) != CATERR_NONE )
8274
		if ( cat.open(file, this->getAddonDir(), CATREAD_CATDECRYPT, false) != CATERR_NONE )
Line 8282... Line 8282...
8282
			// is a text file
8282
			// is a text file
8283
			sF = sF.findReplace("\\", "/");
8283
			sF = sF.findReplace("\\", "/");
8284
			if ( !sF.token("/", 1).Compare("t") )
8284
			if ( !sF.token("/", 1).Compare("t") )
8285
				continue;
8285
				continue;
8286
 
8286
 
8287
			Utils::String baseFile = CFileIO(sF).baseName();
8287
			Utils::WString baseFile = CFileIO(sF).baseName();
8288
			// check language
8288
			// check language
8289
			int lang = 0;
8289
			int lang = 0;
8290
			if ( baseFile.findPos("-L") != -1 ) // new language file
8290
			if ( baseFile.findPos("-L") != -1 ) // new language file
8291
				lang = baseFile.right(3).toInt();
8291
				lang = baseFile.right(3).toInt();
8292
			else
8292
			else
Line 8297... Line 8297...
8297
 
8297
 
8298
			if ( lang != m_iLanguage )
8298
			if ( lang != m_iLanguage )
8299
				continue;
8299
				continue;
8300
 
8300
 
8301
			// now extract and parse
8301
			// now extract and parse
8302
			if ( cat.extractFile(f->sFile, m_sTempDir + "/" + CFileIO(f->sFile).baseName() + ";.xml") )
8302
			if ( cat.extractFile(f->sFile, m_sTempDir + "/" + CFileIO(f->sFile).baseName().toString() + ";.xml"))
8303
			{
8303
			{
8304
				if ( this->readTextPage(m_sTempDir + "/" + CFileIO(f->sFile).baseName() + ".xml", list, search, page))
8304
				if ( this->readTextPage(m_sTempDir + "/" + CFileIO(f->sFile).baseName().toString() + ".xml", list, search, page))
8305
					done = true;
8305
					done = true;
8306
			}
8306
			}
8307
		}
8307
		}
8308
 
8308
 
8309
		return done;
8309
		return done;
8310
	}
8310
	}
8311
	// otherwise its a normal file
8311
	// otherwise its a normal file
8312
	else if ( CFileIO(file).isFileExtension("pck") )
8312
	else if ( CFileIO(file).isFileExtension(L"pck") )
8313
	{
8313
	{
8314
		C_File f(file);
8314
		C_File f(file);
8315
		if ( !f.ReadFromFile() )
8315
		if ( !f.ReadFromFile() )
8316
			return false;
8316
			return false;
8317
		f.UnPCKFile();
8317
		f.UnPCKFile();
Line 8403... Line 8403...
8403
 
8403
 
8404
 
8404
 
8405
FileType CPackages::adjustFileType(const Utils::String &file, FileType filetype) const
8405
FileType CPackages::adjustFileType(const Utils::String &file, FileType filetype) const
8406
{
8406
{
8407
	CFileIO File(file);
8407
	CFileIO File(file);
8408
	Utils::String dir = File.GetDirIO().topDir();
8408
	Utils::WString dir = File.GetDirIO().topDir();
8409
	Utils::String basename = File.baseName();
8409
	Utils::WString basename = File.baseName();
8410
 
8410
 
8411
	Utils::String ext = File.extension();
8411
	Utils::WString ext = File.extension();
8412
 
8412
 
8413
	// mod files
8413
	// mod files
8414
	if (ext.Compare("cat") || ext.Compare("dat"))
8414
	if (ext.Compare(L"cat") || ext.Compare(L"dat"))
8415
		return FILETYPE_MOD;
8415
		return FILETYPE_MOD;
8416
	// check for text files
8416
	// check for text files
8417
	if ( File.filename().isin("-L") && File.filename().left(4).isNumber() )
8417
	if ( File.filename().contains(L"-L") && File.filename().left(4).isNumber() )
8418
		return FILETYPE_TEXT;
8418
		return FILETYPE_TEXT;
8419
	if ( File.baseName().Compare("conversations") )
8419
	if ( File.baseName().Compare(L"conversations") )
8420
		return FILETYPE_TEXT;
8420
		return FILETYPE_TEXT;
8421
	if ( basename.length() <= 4 && basename.isNumber() && (File.isFileExtension("xml") || File.isFileExtension("pck")) )
8421
	if ( basename.length() <= 4 && basename.isNumber() && (File.isFileExtension(L"xml") || File.isFileExtension(L"pck")) )
8422
		return FILETYPE_TEXT;
8422
		return FILETYPE_TEXT;
8423
	// X2/X3 text file
8423
	// X2/X3 text file
8424
	if ( basename.length() >= 5 && basename.length() <= 8 && ((int)File.baseName()) )
8424
	if ( basename.length() >= 5 && basename.length() <= 8 && ((int)File.baseName()) )
8425
		return FILETYPE_TEXT;
8425
		return FILETYPE_TEXT;
8426
	if ( filetype == FILETYPE_TEXT ) // should no longer be anything text
8426
	if ( filetype == FILETYPE_TEXT ) // should no longer be anything text
8427
		return FILETYPE_SCRIPT;
8427
		return FILETYPE_SCRIPT;
8428
	if ( File.isFileExtension("wav") || File.isFileExtension("mp3") )
8428
	if ( File.isFileExtension(L"wav") || File.isFileExtension(L"mp3") )
8429
		return FILETYPE_SOUND;
8429
		return FILETYPE_SOUND;
8430
	return filetype;
8430
	return filetype;
8431
}
8431
}
8432
 
8432
 
8433
void CPackages::RemoveFailedFiles()
8433
void CPackages::RemoveFailedFiles()
Line 8815... Line 8815...
8815
	p->sAuthor = package->author();
8815
	p->sAuthor = package->author();
8816
	p->sDesc = package->description().findReplace("\n", "::newline::");
8816
	p->sDesc = package->description().findReplace("\n", "::newline::");
8817
	p->sName = package->name();
8817
	p->sName = package->name();
8818
	p->sUpdated = package->creationDate();
8818
	p->sUpdated = package->creationDate();
8819
	p->sVersion = package->version();
8819
	p->sVersion = package->version();
8820
	p->sFilename = CFileIO(package->filename()).filename();
8820
	p->sFilename = CFileIO(package->filename()).filenameStr();
8821
 
8821
 
8822
	return p;
8822
	return p;
8823
}
8823
}
8824
 
8824
 
8825
Utils::String CPackages::FormatAvailablePackageData(CBaseFile *package)
8825
Utils::String CPackages::FormatAvailablePackageData(CBaseFile *package)
Line 9304... Line 9304...
9304
 
9304
 
9305
	HeaderData.CmtBuf=NULL;
9305
	HeaderData.CmtBuf=NULL;
9306
	memset(&OpenArchiveData.Reserved,0,sizeof(OpenArchiveData.Reserved));
9306
	memset(&OpenArchiveData.Reserved,0,sizeof(OpenArchiveData.Reserved));
9307
 
9307
 
9308
	bool error = false;
9308
	bool error = false;
9309
	Utils::String extractedFile = CDirIO(m_sTempDir).file("extracted.tst").findReplace("/", "\\").findReplace("\\\\", "\\");
9309
	Utils::WString extractedFile = CDirIO(m_sTempDir).file("extracted.tst").findReplace(L"/", L"\\").findReplace(L"\\\\", L"\\");
9310
	while ((RHCode=RARReadHeaderEx(hArcData,&HeaderData))==0)
9310
	while ((RHCode=RARReadHeaderEx(hArcData,&HeaderData))==0)
9311
	{
9311
	{
9312
		Utils::String fileName = HeaderData.FileName;
9312
		Utils::String fileName = HeaderData.FileName;
9313
 
9313
 
9314
		if ( HeaderData.FileAttr == 16 )
9314
		if ( HeaderData.FileAttr == 16 )
9315
			continue;
9315
			continue;
9316
		wchar_t wText[200];
-
 
9317
		::MultiByteToWideChar(CP_ACP, NULL, (char *)extractedFile.c_str(), -1, wText, extractedFile.length() + 1);
-
 
9318
		PFCode=RARProcessFileW(hArcData, RAR_EXTRACT, NULL, NULL);
9316
		PFCode=RARProcessFileW(hArcData, RAR_EXTRACT, NULL, NULL);
9319
		if (PFCode!=0)
9317
		if (PFCode!=0)
9320
		{
9318
		{
9321
			error = true;
9319
			error = true;
9322
			break;
9320
			break;
Line 9324... Line 9322...
9324
 
9322
 
9325
		CFileIO File(fileName);
9323
		CFileIO File(fileName);
9326
		if ( File.exists() )
9324
		if ( File.exists() )
9327
		{
9325
		{
9328
			if ( fileName.Compare("pluginmanager.txt") )
9326
			if ( fileName.Compare("pluginmanager.txt") )
9329
				this->readArchiveData(File.fullFilename(), archive);
9327
				this->readArchiveData(File.fullFilenameStr(), archive);
9330
			else
9328
			else
9331
			{
9329
			{
9332
				Utils::String extradir;
9330
				Utils::String extradir;
9333
				int type = SPK::GetAutomaticFiletype(fileName, &extradir, true);
9331
				int type = SPK::GetAutomaticFiletype(fileName, &extradir, true);
9334
				// check for special file types
9332
				// check for special file types
9335
				C_File *f = NULL;
9333
				C_File *f = NULL;
9336
 
9334
 
9337
				if ( type == FILETYPE_SCRIPT_UNINSTALL ) {
9335
				if ( type == FILETYPE_SCRIPT_UNINSTALL ) {
9338
					f = archive->addFile(CFileIO(fileName).filename(), "", FILETYPE_SCRIPT);
9336
					f = archive->addFile(CFileIO(fileName).filenameStr(), "", FILETYPE_SCRIPT);
9339
					if ( f ) {
9337
					if ( f ) {
9340
						f->readFromFile(File.fullFilename());
9338
						f->readFromFile(File.fullFilenameStr());
9341
					}
9339
					}
9342
					type = FILETYPE_UNINSTALL;
9340
					type = FILETYPE_UNINSTALL;
9343
				}
9341
				}
9344
 
9342
 
9345
				if ( type == -1 )
9343
				if ( type == -1 )
9346
					f = archive->addFile(CFileIO(fileName).filename(), CFileIO(fileName).dir(), FILETYPE_EXTRA);
9344
					f = archive->addFile(CFileIO(fileName).filenameStr(), CFileIO(fileName).dirStr(), FILETYPE_EXTRA);
9347
				else
9345
				else
9348
					f = archive->addFile(CFileIO(fileName).filename(), extradir, static_cast<FileType>(type));
9346
					f = archive->addFile(CFileIO(fileName).filenameStr(), extradir, static_cast<FileType>(type));
9349
				f->readFromFile(File.fullFilename());
9347
				f->readFromFile(File.fullFilenameStr());
9350
			}
9348
			}
9351
 
9349
 
9352
			File.remove();
9350
			File.remove();
9353
		}
9351
		}
9354
	}
9352
	}
Line 9425... Line 9423...
9425
			Utils::String extradir;
9423
			Utils::String extradir;
9426
			int type = SPK::GetAutomaticFiletype(Name, &extradir, true);
9424
			int type = SPK::GetAutomaticFiletype(Name, &extradir, true);
9427
 
9425
 
9428
			C_File *f = NULL;
9426
			C_File *f = NULL;
9429
 
9427
 
9430
			Utils::String filename = CFileIO(Name).filename();
9428
			Utils::String filename = CFileIO(Name).filenameStr();
9431
			Utils::String dir = CFileIO(Name).dir();
9429
			Utils::String dir = CFileIO(Name).dirStr();
9432
 
9430
 
9433
			// check for special file types
9431
			// check for special file types
9434
			if ( type == FILETYPE_SCRIPT_UNINSTALL ) {
9432
			if ( type == FILETYPE_SCRIPT_UNINSTALL ) {
9435
				f = archive->addFile(filename, dir, FILETYPE_SCRIPT);
9433
				f = archive->addFile(filename, dir, FILETYPE_SCRIPT);
9436
				if ( f ) {
9434
				if ( f ) {
Line 9473... Line 9471...
9473
 
9471
 
9474
CBaseFile *CPackages::createFromArchive(const Utils::String &filename, bool toInstall) const
9472
CBaseFile *CPackages::createFromArchive(const Utils::String &filename, bool toInstall) const
9475
{
9473
{
9476
	// make sure we can open the zip file
9474
	// make sure we can open the zip file
9477
	CBaseFile *archive = NULL;
9475
	CBaseFile *archive = NULL;
9478
	if ( CFileIO(filename).isFileExtension("rar") )
9476
	if ( CFileIO(filename).isFileExtension(L"rar") )
9479
		archive = this->_archive_fromRar(filename, toInstall);
9477
		archive = this->_archive_fromRar(filename, toInstall);
9480
	else if ( CFileIO(filename).isFileExtension("zip") )
9478
	else if ( CFileIO(filename).isFileExtension(L"zip") )
9481
		archive = this->_archive_fromZip(filename, toInstall);
9479
		archive = this->_archive_fromZip(filename, toInstall);
9482
 
9480
 
9483
	if ( archive ) {
9481
	if ( archive ) {
9484
		archive->setFilename(CFileIO(filename).changeFileExtension("spk"));
9482
		archive->setFilename(CFileIO(filename).changeFileExtension(L"spk").toString());
9485
		if ( toInstall )
9483
		if ( toInstall )
9486
			archive->setName(CFileIO(filename).filename());
9484
			archive->setName(CFileIO(filename).filenameStr());
9487
		else
9485
		else
9488
			archive->setName(CFileIO(filename).baseName());
9486
			archive->setName(CFileIO(filename).baseName().toString());
9489
	}
9487
	}
9490
 
9488
 
9491
	return archive;
9489
	return archive;
9492
}
9490
}
9493
 
9491
 
9494
Utils::String CPackages::CreateFromPackagerScript(CPackages *packages, const Utils::String &filename)
9492
Utils::String CPackages::CreateFromPackagerScript(CPackages *packages, const Utils::String &filename)
9495
{
9493
{
9496
	Utils::String curDir = CFileIO(filename).dir();
9494
	Utils::String curDir = CFileIO(filename).dirStr();
9497
	Utils::CStringList variables;
9495
	Utils::CStringList variables;
9498
	variables.pushBack("$PATH", curDir);
9496
	variables.pushBack("$PATH", curDir);
9499
	CBaseFile *package = packages->LoadPackagerScript(filename, NULL, NULL, NULL, &variables);
9497
	CBaseFile *package = packages->LoadPackagerScript(filename, NULL, NULL, NULL, &variables);
9500
 
9498
 
9501
	if ( !package )
9499
	if ( !package )
Line 9540... Line 9538...
9540
		if(Dir.dirList(files, "", pattern))
9538
		if(Dir.dirList(files, "", pattern))
9541
		{
9539
		{
9542
			for(auto itr = files.begin(); itr != files.end(); itr++)
9540
			for(auto itr = files.begin(); itr != files.end(); itr++)
9543
			{
9541
			{
9544
				int error = 0;
9542
				int error = 0;
9545
				CBaseFile *p = packages.openPackage(Dir.file((*itr)->str), &error, 0, SPKREAD_NODATA);
9543
				CBaseFile *p = packages.openPackage(Dir.file((*itr)->str).toString(), &error, 0, SPKREAD_NODATA);
9546
				if ( !p )
9544
				if ( !p )
9547
					continue;
9545
					continue;
9548
 
9546
 
9549
				if ( includeSingle )
9547
				if ( includeSingle )
9550
					p->createUpdateFile(dir);
9548
					p->createUpdateFile(dir);