Subversion Repositories spk

Rev

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

Rev 220 Rev 221
Line 83... Line 83...
83
	_pCurrentDir = new GameDirectory();
83
	_pCurrentDir = new GameDirectory();
84
	_pCurrentDir->dir = dir;
84
	_pCurrentDir->dir = dir;
85
	_pCurrentDir->id = -1;
85
	_pCurrentDir->id = -1;
86
 
86
 
87
	m_gameExe.getDirectoryData(_pCurrentDir);
87
	m_gameExe.getDirectoryData(_pCurrentDir);
88
	_pCurrentDir->langid = this->getGameLanguage(_pCurrentDir->dir.toString());
88
	_pCurrentDir->langid = this->getGameLanguage(_pCurrentDir->dir);
89
	if (_pCurrentDir->langid > 0)
89
	if (_pCurrentDir->langid > 0)
90
		_pCurrentDir->langname = this->ConvertLanguage(_pCurrentDir->langid);
90
		_pCurrentDir->langname = this->ConvertLanguage(_pCurrentDir->langid);
91
 
91
 
92
	updateFoundPackages(L"");
92
	updateFoundPackages(L"");
93
}
93
}
Line 379... Line 379...
379
					else if ( cmd == L"modifieddisabled" )
379
					else if ( cmd == L"modifieddisabled" )
380
						packageFile->SetModifiedEnabled(false);
380
						packageFile->SetModifiedEnabled(false);
381
					else if ( cmd == L"icon" )
381
					else if ( cmd == L"icon" )
382
					{
382
					{
383
						C_File *icon = new C_File(rest.tokens(L" ", 2));
383
						C_File *icon = new C_File(rest.tokens(L" ", 2));
384
						packageFile->setIcon(icon, rest.token(L" ", 1).toString());
384
						packageFile->setIcon(icon, rest.token(L" ", 1));
385
					}
385
					}
386
					else
386
					else
387
						packageFile->parseValueLine(line);
387
						packageFile->parseValueLine(line);
388
				}
388
				}
389
				else if ( iStatus == READ_SCRIPTFILE )
389
				else if ( iStatus == READ_SCRIPTFILE )
Line 808... Line 808...
808
 
808
 
809
	if ( !useFile.empty() )
809
	if ( !useFile.empty() )
810
	{
810
	{
811
		// lets check whats in the file first
811
		// lets check whats in the file first
812
		CCatFile openCat;
812
		CCatFile openCat;
813
		if ( openCat.open((m_sCurrentDir + L"/" + useFile + L".cat").toString(), addonDir.toString(), CATREAD_CATDECRYPT, false) == CATERR_NONE)
813
		if ( openCat.open((m_sCurrentDir + L"/" + useFile + L".cat"), addonDir, CATREAD_CATDECRYPT, false) == CATERR_NONE)
814
		{
814
		{
815
			std::vector<SInCatFile *> *files = openCat.GetFiles();
815
			std::vector<SInCatFile *> *files = openCat.GetFiles();
816
			bool found = false;
816
			bool found = false;
817
			if ( files )
817
			if ( files )
818
			{
818
			{
Line 1198... Line 1198...
1198
	delete package;
1198
	delete package;
1199
 
1199
 
1200
	return ret;
1200
	return ret;
1201
}
1201
}
1202
 
1202
 
1203
int CPackages::prepareMultiPackage(const Utils::String &file, CLinkList<CBaseFile> *errorPackageList, int *error, CProgressInfo *progress)
1203
int CPackages::prepareMultiPackage(const Utils::WString &file, CLinkList<CBaseFile> *errorPackageList, int *error, CProgressInfo *progress)
1204
{
1204
{
1205
	int check = checkOpenPackage(file, error);
1205
	int check = checkOpenPackage(file, error);
1206
	if ( *error == -1 )
1206
	if ( *error == -1 )
1207
		return 0;
1207
		return 0;
1208
 
1208
 
Line 1377... Line 1377...
1377
}
1377
}
1378
 
1378
 
1379
void CPackages::_addToFakePatch(CBaseFile *pPackage)
1379
void CPackages::_addToFakePatch(CBaseFile *pPackage)
1380
{
1380
{
1381
	CCatFile cat;
1381
	CCatFile cat;
1382
	if ( CCatFile::Opened(cat.open((m_sCurrentDir + L"/PluginManager/PlugMan_Fake.cat").toString(), this->getAddonDir(), CATREAD_DAT))) {
1382
	if ( CCatFile::Opened(cat.open((m_sCurrentDir + L"/PluginManager/PlugMan_Fake.cat"), this->getAddonDir(), CATREAD_DAT))) {
1383
		for ( CListNode<C_File> *f = pPackage->GetFileList()->Front(); f; f = f->next() ) {
1383
		for ( CListNode<C_File> *f = pPackage->GetFileList()->Front(); f; f = f->next() ) {
1384
			if ( f->Data()->GetFileType() != FILETYPE_SHIPSCENE && f->Data()->GetFileType() != FILETYPE_COCKPITSCENE && f->Data()->GetFileType() != FILETYPE_SHIPMODEL && f->Data()->GetFileType() != FILETYPE_SHIPOTHER ) {
1384
			if ( f->Data()->GetFileType() != FILETYPE_SHIPSCENE && f->Data()->GetFileType() != FILETYPE_COCKPITSCENE && f->Data()->GetFileType() != FILETYPE_SHIPMODEL && f->Data()->GetFileType() != FILETYPE_SHIPOTHER ) {
1385
				continue;
1385
				continue;
1386
			}
1386
			}
1387
			if ( CCatFile::IsAddonDir(f->Data()->getNameDirectory(pPackage)) ) {
1387
			if ( CCatFile::IsAddonDir(f->Data()->getNameDirectory(pPackage)) ) {
Line 1492... Line 1492...
1492
 
1492
 
1493
	CLog::log(CLog::Log_Install, 3, L"Reading all files into memory");
1493
	CLog::log(CLog::Log_Install, 3, L"Reading all files into memory");
1494
	package->ReadAllFilesToMemory();
1494
	package->ReadAllFilesToMemory();
1495
 
1495
 
1496
	CLog::log(CLog::Log_Install, 3, L"Starting to install files");
1496
	CLog::log(CLog::Log_Install, 3, L"Starting to install files");
1497
	if ( !package->installFiles (m_sCurrentDir.toString(), progress, &m_lFiles, errors, !disabled, this))
1497
	if ( !package->installFiles (m_sCurrentDir, progress, &m_lFiles, errors, !disabled, this))
1498
	{
1498
	{
1499
		CLog::log(CLog::Log_Install, 2, L"There was an error installing files!!");
1499
		CLog::log(CLog::Log_Install, 2, L"There was an error installing files!!");
1500
 
1500
 
1501
		// TODO: clear up installed files
1501
		// TODO: clear up installed files
1502
		return false;
1502
		return false;
Line 1602... Line 1602...
1602
				{
1602
				{
1603
					if ( f->Data()->baseName().left(5).Compare(L"fake_") )
1603
					if ( f->Data()->baseName().left(5).Compare(L"fake_") )
1604
					{
1604
					{
1605
						shuffle = true;
1605
						shuffle = true;
1606
						C_File *match = package->findMatchingMod(f->Data());
1606
						C_File *match = package->findMatchingMod(f->Data());
1607
						Utils::String next = Utils::String::PadNumber(this->findNextFakePatch(), 2);
1607
						Utils::WString next = Utils::WString::PadNumber(this->findNextFakePatch(), 2);
1608
						
1608
						
1609
						Utils::WString oldFilePointer = f->Data()->filePointer();
1609
						Utils::WString oldFilePointer = f->Data()->filePointer();
1610
						f->Data()->setDir(L"");
1610
						f->Data()->setDir(L"");
1611
						f->Data()->changeBaseName(next);
1611
						f->Data()->changeBaseName(next);
1612
						if ( CFileIO(oldFilePointer).Rename(m_sCurrentDir + L"/" + f->Data()->getNameDirectory(package)))
1612
						if ( CFileIO(oldFilePointer).Rename(m_sCurrentDir + L"/" + f->Data()->getNameDirectory(package)))
Line 2211... Line 2211...
2211
				if ( spk->IsAnotherMod() )
2211
				if ( spk->IsAnotherMod() )
2212
				{
2212
				{
2213
					for ( CListNode<CBaseFile> *node = m_lInstallList.Front(); node; node = node->next() )
2213
					for ( CListNode<CBaseFile> *node = m_lInstallList.Front(); node; node = node->next() )
2214
					{
2214
					{
2215
						CBaseFile *p = node->Data();
2215
						CBaseFile *p = node->Data();
2216
						if ( spk->otherName().Compare(p->name().toString()) && spk->otherAuthor().Compare(p->author().toString()) )
2216
						if ( spk->otherName().Compare(p->name()) && spk->otherAuthor().Compare(p->author()) )
2217
						{
2217
						{
2218
							m_lInstallList.insert(m_lInstallList.FindPos(p) + 2, package);
2218
							m_lInstallList.insert(m_lInstallList.FindPos(p) + 2, package);
2219
							added = true;
2219
							added = true;
2220
							break;
2220
							break;
2221
						}
2221
						}
Line 2233... Line 2233...
2233
 
2233
 
2234
					CSpkFile *spk = (CSpkFile *)node->Data();
2234
					CSpkFile *spk = (CSpkFile *)node->Data();
2235
					if ( !spk->isAnotherMod() )
2235
					if ( !spk->isAnotherMod() )
2236
						continue;
2236
						continue;
2237
 
2237
 
2238
					if ( spk->otherName().Compare(package->name().toString()) && spk->otherAuthor().Compare(package->author().toString()) )
2238
					if ( spk->otherName().Compare(package->name()) && spk->otherAuthor().Compare(package->author()) )
2239
					{
2239
					{
2240
						added = true;
2240
						added = true;
2241
						m_lInstallList.insert(node->Data(), package);
2241
						m_lInstallList.insert(node->Data(), package);
2242
						break;
2242
						break;
2243
					}
2243
					}
Line 2707... Line 2707...
2707
	for(auto itr = _lNonRemovedFiles.begin(); itr != _lNonRemovedFiles.end(); itr++)
2707
	for(auto itr = _lNonRemovedFiles.begin(); itr != _lNonRemovedFiles.end(); itr++)
2708
		lines.pushBack(L"NonRemovedFile: " + (*itr)->str);
2708
		lines.pushBack(L"NonRemovedFile: " + (*itr)->str);
2709
 
2709
 
2710
	if ( m_lGameShips.size() )
2710
	if ( m_lGameShips.size() )
2711
	{
2711
	{
2712
		lines.pushBack(Utils::String(L"Ships: ") + (long)m_lGameShips.size());
2712
		lines.pushBack(Utils::WString(L"Ships: ") + (long)m_lGameShips.size());
2713
 
2713
 
2714
		for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
2714
		for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
2715
		{
2715
		{
2716
			SGameShip *gm = node->Data();
2716
			SGameShip *gm = node->Data();
2717
			lines.pushBack(Utils::WString((long)gm->iType) + L" $#C:" + gm->sShipClass + L" " + gm->sShipID);
2717
			lines.pushBack(Utils::WString((long)gm->iType) + L" $#C:" + gm->sShipClass + L" " + gm->sShipID);
Line 3059... Line 3059...
3059
		if ( !currentFile.exists() )
3059
		if ( !currentFile.exists() )
3060
		{
3060
		{
3061
			// missing file ??
3061
			// missing file ??
3062
			if ( !newFile.exists() )
3062
			if ( !newFile.exists() )
3063
			{
3063
			{
3064
				this->addLogEntry(SPKINSTALL_MISSINGFILE, newFilename.toString(), errors);
3064
				this->addLogEntry(SPKINSTALL_MISSINGFILE, newFilename, errors);
3065
				continue;
3065
				continue;
3066
			}
3066
			}
3067
		}
3067
		}
3068
		// remove existing file
3068
		// remove existing file
3069
		// file exists, so lets try to move it
3069
		// file exists, so lets try to move it
Line 3072... Line 3072...
3072
			if ( newFile.exists() )
3072
			if ( newFile.exists() )
3073
				newFile.remove();
3073
				newFile.remove();
3074
 
3074
 
3075
			if ( !currentFile.Rename(newFile.fullFilename()) )
3075
			if ( !currentFile.Rename(newFile.fullFilename()) )
3076
			{
3076
			{
3077
				this->addLogEntry(SPKINSTALL_ENABLEFILE_FAIL, newFilename.toString(), errors);
3077
				this->addLogEntry(SPKINSTALL_ENABLEFILE_FAIL, newFilename, errors);
3078
				continue;
3078
				continue;
3079
			}
3079
			}
3080
		}
3080
		}
3081
 
3081
 
3082
		this->addLogEntry(SPKINSTALL_ENABLEFILE, newFilename.toString(), errors);
3082
		this->addLogEntry(SPKINSTALL_ENABLEFILE, newFilename, errors);
3083
 
3083
 
3084
		// adjust the internal name to match the new filename
3084
		// adjust the internal name to match the new filename
3085
		f->setFilename((m_sCurrentDir + L"/" + newFilename).toString());
3085
		f->setFilename(m_sCurrentDir + L"/" + newFilename);
3086
		// no longer disabled, we need to remove the flag
3086
		// no longer disabled, we need to remove the flag
3087
		f->SetDisabled(false);
3087
		f->SetDisabled(false);
3088
	}
3088
	}
3089
 
3089
 
3090
	// recursive, auto enable all children
3090
	// recursive, auto enable all children
Line 3196... Line 3196...
3196
				continue;
3196
				continue;
3197
		}
3197
		}
3198
 
3198
 
3199
		if ( f->GetFileType() == FILETYPE_MOD && !f->IsFakePatch() && f->checkFileExt(L"cat") )
3199
		if ( f->GetFileType() == FILETYPE_MOD && !f->IsFakePatch() && f->checkFileExt(L"cat") )
3200
		{
3200
		{
3201
			if ( f->baseName().Compare(m_sSetMod.toString()) )
3201
			if ( f->baseName().Compare(m_sSetMod) )
3202
				m_sSetMod = Utils::WString::Null();
3202
				m_sSetMod = Utils::WString::Null();
3203
		}
3203
		}
3204
 
3204
 
3205
		// file is not being used by any enabled package
3205
		// file is not being used by any enabled package
3206
		// set disabled and move to disabled directory
3206
		// set disabled and move to disabled directory
Line 3280... Line 3280...
3280
			if(!removeDirs.contains(f->getDirectory(checkPackage)))
3280
			if(!removeDirs.contains(f->getDirectory(checkPackage)))
3281
				removeDirs.pushBack(f->getDirectory(checkPackage));
3281
				removeDirs.pushBack(f->getDirectory(checkPackage));
3282
		}
3282
		}
3283
 
3283
 
3284
		// change the filename
3284
		// change the filename
3285
		f->setFilename(newFilename.toString());
3285
		f->setFilename(newFilename);
3286
 
3286
 
3287
		// finally mark the file as disabled so we know not to try to move it again
3287
		// finally mark the file as disabled so we know not to try to move it again
3288
		f->SetDisabled(true);
3288
		f->SetDisabled(true);
3289
	}
3289
	}
3290
 
3290
 
Line 4179... Line 4179...
4179
	
4179
	
4180
			Utils::WString newName = SPK::FormatTextName(current, m_iLanguage, (m_iGameFlags & EXEFLAG_TCTEXT)) + L"." + moveFile.extension();
4180
			Utils::WString newName = SPK::FormatTextName(current, m_iLanguage, (m_iGameFlags & EXEFLAG_TCTEXT)) + L"." + moveFile.extension();
4181
			if ( moveFile.Rename(m_sCurrentDir + L"/t/" + newName) )
4181
			if ( moveFile.Rename(m_sCurrentDir + L"/t/" + newName) )
4182
			{
4182
			{
4183
				this->addLogEntry(SPKINSTALL_AUTOTEXT, f->name() + L"~" + newName, errors);
4183
				this->addLogEntry(SPKINSTALL_AUTOTEXT, f->name() + L"~" + newName, errors);
4184
				f->setName(newName.toString());
4184
				f->setName(newName);
4185
			}
4185
			}
4186
			else
4186
			else
4187
				this->addLogEntry(SPKINSTALL_AUTOTEXT_FAIL, f->name() + L"~" + newName, errors);
4187
				this->addLogEntry(SPKINSTALL_AUTOTEXT_FAIL, f->name() + L"~" + newName, errors);
4188
		}
4188
		}
4189
	}
4189
	}
Line 4474... Line 4474...
4474
			Utils::WString newName2 = Utils::WString::PadNumber(to, 2) + L"." + f2->fileExt();
4474
			Utils::WString newName2 = Utils::WString::PadNumber(to, 2) + L"." + f2->fileExt();
4475
			CFileIO moveFile(f2->filePointer());
4475
			CFileIO moveFile(f2->filePointer());
4476
			if ( moveFile.Rename(m_sCurrentDir + L"/" + newName2) )
4476
			if ( moveFile.Rename(m_sCurrentDir + L"/" + newName2) )
4477
			{
4477
			{
4478
				this->addLogEntry(SPKINSTALL_FAKEPATCH, f2->name() + L"~" + newName2, errors);
4478
				this->addLogEntry(SPKINSTALL_FAKEPATCH, f2->name() + L"~" + newName2, errors);
4479
				f2->setName(newName2.toString());
4479
				f2->setName(newName2);
4480
			}
4480
			}
4481
			else
4481
			else
4482
				this->addLogEntry(SPKINSTALL_FAKEPATCH_FAIL, f2->name() + L"~" + newName2, errors);
4482
				this->addLogEntry(SPKINSTALL_FAKEPATCH_FAIL, f2->name() + L"~" + newName2, errors);
4483
		}
4483
		}
4484
 
4484
 
4485
		// finally make sure the internal name matches the new one
4485
		// finally make sure the internal name matches the new one
4486
		file->setName(newName.toString());
4486
		file->setName(newName);
4487
	}
4487
	}
4488
	else
4488
	else
4489
		this->addLogEntry(SPKINSTALL_FAKEPATCH_FAIL, file->name() + L"~" + newName, errors);
4489
		this->addLogEntry(SPKINSTALL_FAKEPATCH_FAIL, file->name() + L"~" + newName, errors);
4490
}
4490
}
4491
 
4491
 
Line 4517... Line 4517...
4517
	CDirIO Dir((dir.empty()) ? m_sCurrentDir : dir);
4517
	CDirIO Dir((dir.empty()) ? m_sCurrentDir : dir);
4518
 
4518
 
4519
	int check = start;
4519
	int check = start;
4520
	while ( check > 0 )
4520
	while ( check > 0 )
4521
	{
4521
	{
4522
		Utils::WString checkStr = Utils::String::PadNumber(check, 2);
4522
		Utils::WString checkStr = Utils::WString::PadNumber(check, 2);
4523
 
4523
 
4524
		// check if a cat file exists
4524
		// check if a cat file exists
4525
		if ( !Dir.exists(checkStr + L".cat") )
4525
		if ( !Dir.exists(checkStr + L".cat") )
4526
		{
4526
		{
4527
			// it doen't, check if theres a dat file (incase of package error)
4527
			// it doen't, check if theres a dat file (incase of package error)
Line 4566... Line 4566...
4566
 *
4566
 *
4567
 * Searching for the next gap in automatic text files, start with 0004-LXXX or XX0004
4567
 * Searching for the next gap in automatic text files, start with 0004-LXXX or XX0004
4568
 */
4568
 */
4569
unsigned int CPackages::findNextTextFile(unsigned int start) const
4569
unsigned int CPackages::findNextTextFile(unsigned int start) const
4570
{
4570
{
4571
	return findNextTextFile(Utils::String::Null(), start);
4571
	return findNextTextFile(Utils::WString::Null(), start);
4572
}
4572
}
4573
unsigned int CPackages::findNextTextFile(const Utils::WString &dir, unsigned int start) const
4573
unsigned int CPackages::findNextTextFile(const Utils::WString &dir, unsigned int start) const
4574
{
4574
{
4575
	int check = start;
4575
	int check = start;
4576
	if ( check < 2 ) check = 2;
4576
	if ( check < 2 ) check = 2;
Line 4633... Line 4633...
4633
		size_t size;
4633
		size_t size;
4634
		char *data = File.ReadToData(&size);
4634
		char *data = File.ReadToData(&size);
4635
 
4635
 
4636
		if ( data )
4636
		if ( data )
4637
		{
4637
		{
4638
			Utils::String str(data);
4638
			Utils::WString str(data);
4639
			m_iLanguage = str.token("\n", 1).token(" ", 1).toInt();
4639
			m_iLanguage = str.token(L"\n", 1).token(L" ", 1).toInt();
4640
		}
4640
		}
4641
	}
4641
	}
4642
}
4642
}
4643
 
4643
 
4644
/**
4644
/**
Line 5074... Line 5074...
5074
		size_t size;
5074
		size_t size;
5075
		char *data = File.ReadToData(&size);
5075
		char *data = File.ReadToData(&size);
5076
 
5076
 
5077
		if ( data )
5077
		if ( data )
5078
		{
5078
		{
5079
			Utils::String str(data);
5079
			Utils::WString str(data);
5080
			return str.token("\n", 1).token(" ", 1).toLong();
5080
			return str.token(L"\n", 1).token(L" ", 1).toLong();
5081
		}
5081
		}
5082
	}
5082
	}
5083
 
5083
 
5084
	return 0;
5084
	return 0;
5085
}
5085
}
Line 5238... Line 5238...
5238
	else if (!m_sSetMod.empty())
5238
	else if (!m_sSetMod.empty())
5239
	{
5239
	{
5240
		if (CFileIO::Exists(m_sCurrentDir + L"/mods/" + m_sSetMod + L".cat"))
5240
		if (CFileIO::Exists(m_sCurrentDir + L"/mods/" + m_sSetMod + L".cat"))
5241
		{
5241
		{
5242
			CCatFile catFile;
5242
			CCatFile catFile;
5243
			if (catFile.open(m_sCurrentDir + L"/mods/" + m_sSetMod + L".cat", addonDir.toString(), CATREAD_CATDECRYPT, false) == CATERR_NONE)
5243
			if (catFile.open(m_sCurrentDir + L"/mods/" + m_sSetMod + L".cat", addonDir, CATREAD_CATDECRYPT, false) == CATERR_NONE)
5244
			{
5244
			{
5245
				if (catFile.extractFile(aFilename, aTo))
5245
				if (catFile.extractFile(aFilename, aTo))
5246
					return 1;
5246
					return 1;
5247
				if (catFile.error() == CATERR_INVALIDDEST || catFile.error() == CATERR_CANTCREATEDIR)
5247
				if (catFile.error() == CATERR_INVALIDDEST || catFile.error() == CATERR_CANTCREATEDIR)
5248
				{
5248
				{
Line 5263... Line 5263...
5263
 
5263
 
5264
	// work backwards until we find the file
5264
	// work backwards until we find the file
5265
	for (; catNumber; catNumber--)
5265
	for (; catNumber; catNumber--)
5266
	{
5266
	{
5267
		CCatFile catFile;
5267
		CCatFile catFile;
5268
		if (catFile.open((dir + L"/" + Utils::WString::PadNumber(catNumber, 2) + L".cat"), addonDir.toString(), CATREAD_CATDECRYPT, false) == CATERR_NONE)
5268
		if (catFile.open((dir + L"/" + Utils::WString::PadNumber(catNumber, 2) + L".cat"), addonDir, CATREAD_CATDECRYPT, false) == CATERR_NONE)
5269
		{
5269
		{
5270
			// check for the file
5270
			// check for the file
5271
			if (catFile.extractFile(aFilename, aTo))
5271
			if (catFile.extractFile(aFilename, aTo))
5272
				return 1;
5272
				return 1;
5273
			if (catFile.error() == CATERR_INVALIDDEST || catFile.error() == CATERR_CANTCREATEDIR)
5273
			if (catFile.error() == CATERR_INVALIDDEST || catFile.error() == CATERR_CANTCREATEDIR)
Line 5393... Line 5393...
5393
					}
5393
					}
5394
				}
5394
				}
5395
 
5395
 
5396
				if ( create )
5396
				if ( create )
5397
				{
5397
				{
5398
					wareLines.pushFront(Utils::String::Number(version) + ";" + Utils::String::Number(wareLines.size()) + ";", Utils::String::Null());
5398
					wareLines.pushFront(Utils::WString::Number(version) + L";" + Utils::WString::Number(wareLines.size()) + L";", Utils::WString::Null());
5399
					Utils::WString strV = Utils::WString::FromFloat(GetLibraryVersion(), 2);
5399
					Utils::WString strV = Utils::WString::FromFloat(GetLibraryVersion(), 2);
5400
					wareLines.pushFront("// Created by SPKInstaller Libraries V" + strV, Utils::WString::Null());
5400
					wareLines.pushFront("// Created by SPKInstaller Libraries V" + strV, Utils::WString::Null());
5401
					if ( readFile.writeFile(&wareLines) )
5401
					if ( readFile.writeFile(&wareLines) )
5402
						this->packFile(&readFile, L"types\\" + wareFile + L".pck");
5402
						this->packFile(&readFile, L"types\\" + wareFile + L".pck");
5403
				}
5403
				}
Line 5430... Line 5430...
5430
	{
5430
	{
5431
		if ( maxsize ) (*maxsize) = EMP_X3;
5431
		if ( maxsize ) (*maxsize) = EMP_X3;
5432
		return GetX3Emp();
5432
		return GetX3Emp();
5433
	}
5433
	}
5434
 
5434
 
5435
	return Utils::String::Null();
5435
	return Utils::WString::Null();
5436
}
5436
}
5437
 
5437
 
5438
void CPackages::_addWareOverride(enum WareTypes type, int pos, const Utils::WString &id, int value, bool noto)
5438
void CPackages::_addWareOverride(enum WareTypes type, int pos, const Utils::WString &id, int value, bool noto)
5439
{
5439
{
5440
	for(CListNode<SWarePriceOverride> *node = m_lWarePrices.Front(); node; node = node->next()) {
5440
	for(CListNode<SWarePriceOverride> *node = m_lWarePrices.Front(); node; node = node->next()) {
Line 5491... Line 5491...
5491
{
5491
{
5492
	_addWareOverride(Ware_Custom, 0, id, noto, true);
5492
	_addWareOverride(Ware_Custom, 0, id, noto, true);
5493
}
5493
}
5494
 
5494
 
5495
 
5495
 
5496
void CPackages::createEMPFile(const Utils::String &progDir)
5496
void CPackages::createEMPFile(const Utils::WString &progDir)
5497
{
5497
{
5498
	// do emp wares
5498
	// do emp wares
5499
	size_t maxsize = 0;
5499
	size_t maxsize = 0;
5500
	Utils::WString empWares = empWaresForGame(&maxsize);
5500
	Utils::WString empWares = empWaresForGame(&maxsize);
5501
 
5501
 
Line 6066... Line 6066...
6066
void CPackages::backupSaves(bool vanilla)
6066
void CPackages::backupSaves(bool vanilla)
6067
{
6067
{
6068
	if (!_sSaveDir.empty())
6068
	if (!_sSaveDir.empty())
6069
	{
6069
	{
6070
		// copy any saves into the vanilla directory
6070
		// copy any saves into the vanilla directory
6071
		Utils::String dir = (vanilla) ? "Vanilla" : "Modified";
6071
		Utils::WString dir = (vanilla) ? L"Vanilla" : L"Modified";
6072
 
6072
 
6073
		// make sure the directory exists
6073
		// make sure the directory exists
6074
		CDirIO saveDir(this->saveDirectory());
6074
		CDirIO saveDir(this->saveDirectory());
6075
		CDirIO gameSaveDir(saveDir.dir(_sSaveDir));
6075
		CDirIO gameSaveDir(saveDir.dir(_sSaveDir));
6076
 
6076
 
Line 6103... Line 6103...
6103
void CPackages::restoreSaves(bool vanilla)
6103
void CPackages::restoreSaves(bool vanilla)
6104
{
6104
{
6105
	// get dir to restore from
6105
	// get dir to restore from
6106
	if (!_sSaveDir.empty())
6106
	if (!_sSaveDir.empty())
6107
	{
6107
	{
6108
		Utils::String dir = (vanilla) ? "Vanilla" : "Modified";
6108
		Utils::WString dir = (vanilla) ? L"Vanilla" : L"Modified";
6109
		CDirIO toDir(this->saveDirectory());
6109
		CDirIO toDir(this->saveDirectory());
6110
		CDirIO restoreDir(toDir.dir(_sSaveDir));
6110
		CDirIO restoreDir(toDir.dir(_sSaveDir));
6111
		restoreDir.cd(dir);
6111
		restoreDir.cd(dir);
6112
 
6112
 
6113
		if (restoreDir.exists())
6113
		if (restoreDir.exists())
Line 6483... Line 6483...
6483
			if(File.readLines(lines))
6483
			if(File.readLines(lines))
6484
			{
6484
			{
6485
				for ( int j = 0; j < (int)lines.size(); j++ )
6485
				for ( int j = 0; j < (int)lines.size(); j++ )
6486
				{
6486
				{
6487
					Utils::WString line(lines.at(j));
6487
					Utils::WString line(lines.at(j));
6488
					aniList.pushBack(line.toString());
6488
					aniList.pushBack(line);
6489
				}
6489
				}
6490
			}
6490
			}
6491
 
6491
 
6492
			File.remove();
6492
			File.remove();
6493
		}
6493
		}
Line 6506... Line 6506...
6506
		if ( !s->pPackage->anyAnimations() )
6506
		if ( !s->pPackage->anyAnimations() )
6507
			continue;
6507
			continue;
6508
 
6508
 
6509
		// add each dummy to list
6509
		// add each dummy to list
6510
		for(auto itr = s->pPackage->getAnimations().begin(); itr != s->pPackage->getAnimations().end(); itr++)
6510
		for(auto itr = s->pPackage->getAnimations().begin(); itr != s->pPackage->getAnimations().end(); itr++)
6511
			parsedAniList.pushBack((*itr)->str.toString());
6511
			parsedAniList.pushBack((*itr)->str);
6512
	}
6512
	}
6513
 
6513
 
6514
	// format the list with added spaces
6514
	// format the list with added spaces
6515
	Utils::WStringList formatedAniList;
6515
	Utils::WStringList formatedAniList;
6516
	int lineCount = -1;
6516
	int lineCount = -1;
Line 6626... Line 6626...
6626
	if ( e )
6626
	if ( e )
6627
	{
6627
	{
6628
		CFileIO File;
6628
		CFileIO File;
6629
		if ( File.open((e == -1) ? L"Bodies.txt" : m_sTempDir + L"/Bodies.txt") )
6629
		if ( File.open((e == -1) ? L"Bodies.txt" : m_sTempDir + L"/Bodies.txt") )
6630
		{
6630
		{
6631
			std::vector<Utils::String> *lines = File.readLines();
6631
			std::vector<Utils::WString> lines;
6632
			if ( lines )
6632
			if(File.readLines(lines))
6633
			{
6633
			{
6634
				int entries = 0;
6634
				int entries = 0;
6635
				for ( int j = 0; j < (int)lines->size(); j++ )
6635
				for (size_t j = 0; j < lines.size(); j++ )
6636
				{
6636
				{
6637
					Utils::String line(lines->at(j));
6637
					Utils::WString line(lines.at(j));
6638
					line.removeChar(' ');
6638
					line.removeChar(' ');
6639
					line.removeChar(9);
6639
					line.removeChar(9);
6640
					if ( line.empty() || line[0] == '/' )
6640
					if ( line.empty() || line[0] == '/' )
6641
						continue;
6641
						continue;
6642
					if ( entries <= 0 )
6642
					if ( entries <= 0 )
6643
					{
6643
					{
6644
						entries = line.token(";", 2).toInt();
6644
						entries = line.token(L";", 2).toInt();
6645
						currentSection = new SBodies;
6645
						currentSection = new SBodies;
6646
						currentSection->sSection = line.token(";", 1).toWString();
6646
						currentSection->sSection = line.token(L";", 1);
6647
						bodiesList.push_back(currentSection);
6647
						bodiesList.push_back(currentSection);
6648
					}
6648
					}
6649
					else if ( currentSection )
6649
					else if ( currentSection )
6650
					{
6650
					{
6651
						int num;
-
 
6652
						Utils::String *strs = line.tokenise(";", &num);
6651
						std::vector<Utils::WString> strs;
6653
						if ( num && strs )
6652
						if(line.tokenise(L";", strs))
6654
						{
6653
						{
6655
							for ( int i = 0; i < num; i++ )
6654
							for (size_t i = 0; i < strs.size(); i++)
6656
							{
6655
							{
6657
								if ( strs[i].empty() )
6656
								if ( strs[i].empty() )
6658
									continue;
6657
									continue;
6659
								if(!currentSection->lEntries.contains(strs[i].toWString() + L";"))
6658
								if(!currentSection->lEntries.contains(strs[i] + L";"))
6660
									currentSection->lEntries.pushBack(strs[i].toWString() + L";");
6659
									currentSection->lEntries.pushBack(strs[i] + L";");
6661
								--entries;
6660
								--entries;
6662
							}
6661
							}
6663
						}
6662
						}
6664
						CLEANSPLIT(strs, num);
-
 
6665
					}
6663
					}
6666
				}
6664
				}
6667
 
-
 
6668
				delete lines;
-
 
6669
			}
6665
			}
6670
			File.remove();
6666
			File.remove();
6671
		}
6667
		}
6672
	}
6668
	}
6673
 
6669
 
Line 6711... Line 6707...
6711
				foundSection->lEntries.pushBack(body);
6707
				foundSection->lEntries.pushBack(body);
6712
		}
6708
		}
6713
	}
6709
	}
6714
 
6710
 
6715
	// now write the file
6711
	// now write the file
6716
	std::vector<Utils::String> writeList;
6712
	std::vector<Utils::WString> writeList;
6717
	// the header first
6713
	// the header first
6718
	writeList.push_back("// Bodies file, created by SPK Libraries V" + Utils::String::FromFloat(GetLibraryVersion(), 2));
6714
	writeList.push_back(L"// Bodies file, created by SPK Libraries V" + Utils::WString::FromFloat(GetLibraryVersion(), 2));
6719
	writeList.push_back("//body type;num bodies;");
6715
	writeList.push_back(L"//body type;num bodies;");
6720
	writeList.push_back("//[body id/name]");
6716
	writeList.push_back(L"//[body id/name]");
6721
 
6717
 
6722
	// now our sections
6718
	// now our sections
6723
	for ( SBodies *bSection = bodiesList.First(); bSection; bSection = bodiesList.Next() )
6719
	for ( SBodies *bSection = bodiesList.First(); bSection; bSection = bodiesList.Next() )
6724
	{
6720
	{
6725
		writeList.push_back("");
6721
		writeList.push_back(L"");
6726
		writeList.push_back("// Section: " + bSection->sSection.toString());
6722
		writeList.push_back(L"// Section: " + bSection->sSection);
6727
		writeList.push_back(bSection->sSection.toString() + ";" + Utils::String::Number(bSection->lEntries.size()) + ";");
6723
		writeList.push_back(bSection->sSection + L";" + Utils::WString::Number(bSection->lEntries.size()) + L";");
6728
		for(auto itr = bSection->lEntries.begin(); itr != bSection->lEntries.end(); itr++)
6724
		for(auto itr = bSection->lEntries.begin(); itr != bSection->lEntries.end(); itr++)
6729
		{
6725
		{
6730
			Utils::WString str = (*itr)->str;
6726
			Utils::WString str = (*itr)->str;
6731
			str.removeChar(9);
6727
			str.removeChar(9);
6732
			str.removeChar(' ');
6728
			str.removeChar(' ');
6733
			if ( str.right(1) != L";" )
6729
			if ( str.right(1) != L";" )
6734
				str += L";";
6730
				str += L";";
6735
			writeList.push_back(str.toString());
6731
			writeList.push_back(str);
6736
		}
6732
		}
6737
	}
6733
	}
6738
 
6734
 
6739
	// write the file to disk
6735
	// write the file to disk
6740
	CFileIO WriteFile(m_sTempDir + L"/Bodies.txt");
6736
	CFileIO WriteFile(m_sTempDir + L"/Bodies.txt");
6741
	if ( WriteFile.writeFile(&writeList) )
6737
	if ( WriteFile.writeFile(writeList) )
6742
	{
6738
	{
6743
		this->packFile(&WriteFile, L"types\\Bodies.pck");
6739
		this->packFile(&WriteFile, L"types\\Bodies.pck");
6744
		WriteFile.remove();
6740
		WriteFile.remove();
6745
	}
6741
	}
6746
}
6742
}
Line 7415... Line 7411...
7415
			if ( checkxml )
7411
			if ( checkxml )
7416
			{
7412
			{
7417
				int readmaxlines = 20;
7413
				int readmaxlines = 20;
7418
				bool isxml = false;
7414
				bool isxml = false;
7419
				do {
7415
				do {
7420
					Utils::String line = pckFile.readEndOfLineStr();
7416
					Utils::WString line = pckFile.readEndOfLine();
7421
					if ( line.contains("<language id=") )
7417
					if ( line.contains(L"<language id=") )
7422
					{
7418
					{
7423
						isxml = true;
7419
						isxml = true;
7424
						break;
7420
						break;
7425
					}
7421
					}
7426
					else if ( line.contains("<page id=") )
7422
					else if ( line.contains(L"<page id=") )
7427
					{
7423
					{
7428
						isxml = true;
7424
						isxml = true;
7429
						break;
7425
						break;
7430
					}
7426
					}
7431
					else if ( line.contains("<?xml") || line.contains("<script>") )
7427
					else if ( line.contains(L"<?xml") || line.contains(L"<script>") )
7432
					{
7428
					{
7433
						isxml = true;
7429
						isxml = true;
7434
						break;
7430
						break;
7435
					}
7431
					}
7436
					--readmaxlines;
7432
					--readmaxlines;
Line 7610... Line 7606...
7610
	}
7606
	}
7611
 
7607
 
7612
	return list.size();
7608
	return list.size();
7613
}
7609
}
7614
 
7610
 
7615
CBaseFile *CPackages::findScriptByAuthor(const Utils::String &author, CBaseFile *prev)
7611
CBaseFile *CPackages::findScriptByAuthor(const Utils::WString &author, CBaseFile *prev)
7616
{
7612
{
7617
	for ( CListNode<CBaseFile> *node = m_lPackages.Front(); node; node = node->next() )
7613
	for ( CListNode<CBaseFile> *node = m_lPackages.Front(); node; node = node->next() )
7618
	{
7614
	{
7619
		CBaseFile *p = node->Data();
7615
		CBaseFile *p = node->Data();
7620
		if ( prev )
7616
		if ( prev )
Line 7628... Line 7624...
7628
	}
7624
	}
7629
 
7625
 
7630
	return NULL;
7626
	return NULL;
7631
}
7627
}
7632
 
7628
 
7633
bool CPackages::extractAll(CBaseFile *baseFile, const Utils::String &dir, int game, bool includedir, CProgressInfo *progress) const
7629
bool CPackages::extractAll(CBaseFile *baseFile, const Utils::WString &dir, int game, bool includedir, CProgressInfo *progress) const
7634
{
7630
{
7635
	if (!baseFile)
7631
	if (!baseFile)
7636
		return false;
7632
		return false;
7637
 
7633
 
7638
	Utils::WStringList gameAddons;
7634
	Utils::WStringList gameAddons;
Line 7856... Line 7852...
7856
			for (auto node = package->fileList().Front(); node; node = node->next())
7852
			for (auto node = package->fileList().Front(); node; node = node->next())
7857
			{
7853
			{
7858
				C_File *f = node->Data();
7854
				C_File *f = node->Data();
7859
				if (f->game() && f->game() != GAME_ALLNEW && !(f->game() & (1 << game)))
7855
				if (f->game() && f->game() != GAME_ALLNEW && !(f->game() & (1 << game)))
7860
					continue;
7856
					continue;
7861
				package->extractFile(f, itr->second.toString(), game, gameAddons);
7857
				package->extractFile(f, itr->second, game, gameAddons);
7862
			}
7858
			}
7863
		}
7859
		}
7864
	}
7860
	}
7865
 
7861
 
7866
	if (package->autoExporter())
7862
	if (package->autoExporter())
7867
	{
7863
	{
7868
		for (auto itr = package->autoExporter()->begin(); itr != package->autoExporter()->end(); itr++)
7864
		for (auto itr = package->autoExporter()->begin(); itr != package->autoExporter()->end(); itr++)
7869
			package->saveToArchive(itr->second.toString(), itr->first, &m_gameExe);
7865
			package->saveToArchive(itr->second, itr->first, &m_gameExe);
7870
	}
7866
	}
7871
 
7867
 
7872
	if ( !ftpaddr.empty() )
7868
	if ( !ftpaddr.empty() )
7873
	{
7869
	{
7874
		if ( !ftpuser.empty() )
7870
		if ( !ftpuser.empty() )
7875
		{
7871
		{
7876
			if ( !ftppass.empty() )
7872
			if ( !ftppass.empty() )
7877
				ftpaddr = ftpuser + ":" + ftppass + "@" + ftpaddr;
7873
				ftpaddr = ftpuser + L":" + ftppass + L"@" + ftpaddr;
7878
			else
7874
			else
7879
				ftpaddr = ftpuser + "@" + ftpaddr;
7875
				ftpaddr = ftpuser + L"@" + ftpaddr;
7880
		}
7876
		}
7881
 
7877
 
7882
		if ( !ftpdir.empty() )
7878
		if ( !ftpdir.empty() )
7883
			ftpaddr += ftpdir;
7879
			ftpaddr += ftpdir;
7884
 
7880
 
7885
		package->setFtpAddr(ftpaddr.toString());
7881
		package->setFtpAddr(ftpaddr);
7886
	}
7882
	}
7887
 
7883
 
7888
	return package;
7884
	return package;
7889
}
7885
}
7890
 
7886
 
Line 7939... Line 7935...
7939
	{
7935
	{
7940
		for (auto itr = files.begin(); itr != files.end(); itr++)
7936
		for (auto itr = files.begin(); itr != files.end(); itr++)
7941
		{
7937
		{
7942
			Utils::WString d = Dir.file((*itr)->str);
7938
			Utils::WString d = Dir.file((*itr)->str);
7943
			if (CDirIO(d).isDir())
7939
			if (CDirIO(d).isDir())
7944
				count += findPackageDirectories(packages, d.toString());
7940
				count += findPackageDirectories(packages, d);
7945
		}
7941
		}
7946
	}
7942
	}
7947
 
7943
 
7948
	count += findPackageFiles(packages, dir);
7944
	count += findPackageFiles(packages, dir);
7949
	return count;
7945
	return count;
Line 8231... Line 8227...
8231
	if ( CFileIO(file).isFileExtension(L"cat") )
8227
	if ( CFileIO(file).isFileExtension(L"cat") )
8232
	{
8228
	{
8233
		bool done = false;
8229
		bool done = false;
8234
 
8230
 
8235
		CCatFile cat;
8231
		CCatFile cat;
8236
		if ( cat.open(file, this->getAddonDir().toString(), CATREAD_CATDECRYPT, false) != CATERR_NONE)
8232
		if ( cat.open(file, this->getAddonDir(), CATREAD_CATDECRYPT, false) != CATERR_NONE)
8237
			return false;
8233
			return false;
8238
 
8234
 
8239
		// extract 1 at a time
8235
		// extract 1 at a time
8240
		for (unsigned int i = 0; i < cat.GetNumFiles(); i++ )
8236
		for (unsigned int i = 0; i < cat.GetNumFiles(); i++ )
8241
		{
8237
		{
Line 8402... Line 8398...
8402
	}
8398
	}
8403
	for (auto itr = removed.begin(); itr != removed.end(); itr++)
8399
	for (auto itr = removed.begin(); itr != removed.end(); itr++)
8404
		_lNonRemovedFiles.remove((*itr)->str);
8400
		_lNonRemovedFiles.remove((*itr)->str);
8405
}
8401
}
8406
 
8402
 
8407
CXspFile *CPackages::extractShip(const Utils::String &sCatFile, const Utils::String &sId, CProgressInfo *progress)
8403
CXspFile *CPackages::extractShip(const Utils::WString &sCatFile, const Utils::WString &sId, CProgressInfo *progress)
8408
{
8404
{
8409
	CVirtualFileSystem *pVfs = new CVirtualFileSystem();
8405
	CVirtualFileSystem *pVfs = new CVirtualFileSystem();
8410
	if ( !pVfs->addMod(sCatFile) ) {
8406
	if ( !pVfs->addMod(sCatFile) ) {
8411
		delete pVfs;
8407
		delete pVfs;
8412
		return NULL;
8408
		return NULL;
Line 8541... Line 8537...
8541
	if ( file->GetFileType() != FILETYPE_MOD ) return false;
8537
	if ( file->GetFileType() != FILETYPE_MOD ) return false;
8542
	if ( !file->fileExt().Compare(L"cat") ) return false;
8538
	if ( !file->fileExt().Compare(L"cat") ) return false;
8543
 
8539
 
8544
	// we need to read the file list for the mod
8540
	// we need to read the file list for the mod
8545
	CCatFile cat;
8541
	CCatFile cat;
8546
	if ( cat.open(file->filePointer(), this->getAddonDir().toString(), CATREAD_JUSTCONTENTS, false) == CATERR_NONE)
8542
	if ( cat.open(file->filePointer(), this->getAddonDir(), CATREAD_JUSTCONTENTS, false) == CATERR_NONE)
8547
	{
8543
	{
8548
		for (unsigned int i = 0; i < cat.GetNumFiles(); i++ )
8544
		for (unsigned int i = 0; i < cat.GetNumFiles(); i++ )
8549
		{
8545
		{
8550
			SInCatFile *f = cat.GetFile(i);
8546
			SInCatFile *f = cat.GetFile(i);
8551
			Utils::WString filename = f->sFile;
8547
			Utils::WString filename = f->sFile;
Line 8693... Line 8689...
8693
		C_File *f = fNode->Data();
8689
		C_File *f = fNode->Data();
8694
		if ( f->GetFileType() != FILETYPE_MOD ) continue;
8690
		if ( f->GetFileType() != FILETYPE_MOD ) continue;
8695
		if ( !f->IsFakePatch() ) continue;
8691
		if ( !f->IsFakePatch() ) continue;
8696
		if (!f->checkFileExt(L"cat")) continue;
8692
		if (!f->checkFileExt(L"cat")) continue;
8697
 
8693
 
8698
		if (newFile->extractFile(f, m_sTempDir.toString()) )
8694
		if (newFile->extractFile(f, m_sTempDir) )
8699
			f->setFullDir(m_sTempDir);
8695
			f->setFullDir(m_sTempDir);
8700
	}
8696
	}
8701
 
8697
 
8702
	// compare mod files against all installed packages
8698
	// compare mod files against all installed packages
8703
	int count = 0;
8699
	int count = 0;
Line 9129... Line 9125...
9129
		list->pushBack(L"http://xpluginmanager.co.uk/flscripts");
9125
		list->pushBack(L"http://xpluginmanager.co.uk/flscripts");
9130
 
9126
 
9131
	return list->size();
9127
	return list->size();
9132
}
9128
}
9133
 
9129
 
9134
void CPackages::readArchiveData(const Utils::String &filename, CBaseFile *archive) const
9130
void CPackages::readArchiveData(const Utils::WString &filename, CBaseFile *archive) const
9135
{
9131
{
9136
	size_t size;
9132
	size_t size;
9137
	char *data = CFileIO(filename).ReadToData(&size);
9133
	char *data = CFileIO(filename).ReadToData(&size);
9138
	if ( size && data )
9134
	if ( size && data )
9139
		readArchiveData(data, size, archive);
9135
		readArchiveData(data, size, archive);
Line 9203... Line 9199...
9203
			}
9199
			}
9204
		}
9200
		}
9205
	}
9201
	}
9206
}
9202
}
9207
 
9203
 
9208
CBaseFile *CPackages::_archive_fromRar(const Utils::String &filename, bool toInstall) const
9204
CBaseFile *CPackages::_archive_fromRar(const Utils::WString &filename, bool toInstall) const
9209
{
9205
{
9210
	// make sure we can open the zip file
9206
	// make sure we can open the zip file
9211
	CBaseFile *archive = NULL;
9207
	CBaseFile *archive = NULL;
9212
#ifdef _RAR
9208
#ifdef _RAR
9213
	HANDLE hArcData;
9209
	HANDLE hArcData;
Line 9229... Line 9225...
9229
 
9225
 
9230
		HeaderData.CmtBuf=NULL;
9226
		HeaderData.CmtBuf=NULL;
9231
		memset(&OpenArchiveData.Reserved,0,sizeof(OpenArchiveData.Reserved));
9227
		memset(&OpenArchiveData.Reserved,0,sizeof(OpenArchiveData.Reserved));
9232
 
9228
 
9233
		while ((RHCode=RARReadHeaderEx(hArcData,&HeaderData))==0) {
9229
		while ((RHCode=RARReadHeaderEx(hArcData,&HeaderData))==0) {
9234
			if ( Utils::String(HeaderData.FileName).Compare("pluginmanager.txt") ) {
9230
			if ( Utils::WString(HeaderData.FileName).Compare(L"pluginmanager.txt") ) {
9235
				toInstall = false;
9231
				toInstall = false;
9236
				break;
9232
				break;
9237
			}
9233
			}
9238
		}
9234
		}
9239
		RARCloseArchive(hArcData);
9235
		RARCloseArchive(hArcData);
Line 9313... Line 9309...
9313
#endif
9309
#endif
9314
 
9310
 
9315
	return archive;
9311
	return archive;
9316
}
9312
}
9317
 
9313
 
9318
CBaseFile *CPackages::_archive_fromZip(const Utils::String &filename, bool toInstall) const
9314
CBaseFile *CPackages::_archive_fromZip(const Utils::WString &filename, bool toInstall) const
9319
{
9315
{
9320
	CBaseFile *archive = NULL;
9316
	CBaseFile *archive = NULL;
9321
 
9317
 
9322
	TCHAR buf[5000];
9318
	TCHAR buf[5000];
9323
	wsprintf(buf, L"%hs", filename.c_str());
9319
	wsprintf(buf, L"%hs", filename.c_str());
Line 9360... Line 9356...
9360
 
9356
 
9361
 
9357
 
9362
		char *iBuf = new char[ze.unc_size];
9358
		char *iBuf = new char[ze.unc_size];
9363
		UnzipItem(hz, zi, iBuf, ze.unc_size);
9359
		UnzipItem(hz, zi, iBuf, ze.unc_size);
9364
 
9360
 
9365
		Utils::String Name(ze.name);
9361
		Utils::WString Name(ze.name);
9366
 
9362
 
9367
		// if its the data file, dont add it, but extract to get settings from
9363
		// if its the data file, dont add it, but extract to get settings from
9368
		if ( Name.Compare("pluginmanager.txt") )
9364
		if ( Name.Compare("pluginmanager.txt") )
9369
		{
9365
		{
9370
			this->readArchiveData(iBuf, ze.unc_size, archive);
9366
			this->readArchiveData(iBuf, ze.unc_size, archive);
Line 9419... Line 9415...
9419
		archive = NULL;
9415
		archive = NULL;
9420
	}
9416
	}
9421
	return archive;
9417
	return archive;
9422
}
9418
}
9423
 
9419
 
9424
CBaseFile *CPackages::createFromArchive(const Utils::String &filename, bool toInstall) const
9420
CBaseFile *CPackages::createFromArchive(const Utils::WString &filename, bool toInstall) const
9425
{
9421
{
9426
	// make sure we can open the zip file
9422
	// make sure we can open the zip file
9427
	CBaseFile *archive = NULL;
9423
	CBaseFile *archive = NULL;
9428
	if ( CFileIO(filename).isFileExtension(L"rar") )
9424
	if ( CFileIO(filename).isFileExtension(L"rar") )
9429
		archive = this->_archive_fromRar(filename, toInstall);
9425
		archive = this->_archive_fromRar(filename, toInstall);
9430
	else if ( CFileIO(filename).isFileExtension(L"zip") )
9426
	else if ( CFileIO(filename).isFileExtension(L"zip") )
9431
		archive = this->_archive_fromZip(filename, toInstall);
9427
		archive = this->_archive_fromZip(filename, toInstall);
9432
 
9428
 
9433
	if ( archive ) {
9429
	if ( archive ) {
9434
		archive->setFilename(CFileIO(filename).changeFileExtension(L"spk").toString());
9430
		archive->setFilename(CFileIO(filename).changeFileExtension(L"spk"));
9435
		if ( toInstall )
9431
		if ( toInstall )
9436
			archive->setName(CFileIO(filename).filenameStr());
9432
			archive->setName(CFileIO(filename).filenameStr());
9437
		else
9433
		else
9438
			archive->setName(CFileIO(filename).baseName().toString());
9434
			archive->setName(CFileIO(filename).baseName());
9439
	}
9435
	}
9440
 
9436
 
9441
	return archive;
9437
	return archive;
9442
}
9438
}
9443
 
9439
 
Line 9447... Line 9443...
9447
	Utils::WStringList variables;
9443
	Utils::WStringList variables;
9448
	variables.pushBack(L"$PATH", curDir);
9444
	variables.pushBack(L"$PATH", curDir);
9449
	CBaseFile *package = packages->loadPackagerScript(filename, NULL, NULL, NULL, &variables);
9445
	CBaseFile *package = packages->loadPackagerScript(filename, NULL, NULL, NULL, &variables);
9450
 
9446
 
9451
	if ( !package )
9447
	if ( !package )
9452
		return Utils::String::Null();
9448
		return Utils::WString::Null();
9453
 
9449
 
9454
	Utils::WString saveto = package->filename();
9450
	Utils::WString saveto = package->filename();
9455
	saveto = saveto.findReplace(L"$DEFAULTDIR", curDir + L"/");
9451
	saveto = saveto.findReplace(L"$DEFAULTDIR", curDir + L"/");
9456
	saveto = saveto.findReplace(L"$PATH", curDir);
9452
	saveto = saveto.findReplace(L"$PATH", curDir);
9457
	saveto = saveto.findReplace(L"\\", L"/");
9453
	saveto = saveto.findReplace(L"\\", L"/");
Line 9460... Line 9456...
9460
		saveto += L".spk";
9456
		saveto += L".spk";
9461
	else if ( !saveto.right(4).Compare(L".xsp") && package->GetType() == TYPE_XSP )
9457
	else if ( !saveto.right(4).Compare(L".xsp") && package->GetType() == TYPE_XSP )
9462
		saveto += L".xsp";
9458
		saveto += L".xsp";
9463
 
9459
 
9464
	// write script
9460
	// write script
9465
	if ( package->writeFile(saveto.toString()) )
9461
	if ( package->writeFile(saveto) )
9466
	{
9462
	{
9467
		if ( package->AutoGenerateUpdateFile() )
9463
		if ( package->AutoGenerateUpdateFile() )
9468
			package->createUpdateFile(CFileIO(saveto).dir());
9464
			package->createUpdateFile(CFileIO(saveto).dir());
9469
		return saveto;
9465
		return saveto;
9470
	}
9466
	}
9471
 
9467
 
9472
	return Utils::String::Null();
9468
	return Utils::WString::Null();
9473
}
9469
}
9474
 
9470
 
9475
int CPackages::GeneratePackageUpdateData(const Utils::WString &dir, bool includeSingle)
9471
int CPackages::GeneratePackageUpdateData(const Utils::WString &dir, bool includeSingle)
9476
{
9472
{
9477
	Utils::WStringList filedata;
9473
	Utils::WStringList filedata;