Subversion Repositories spk

Rev

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

Rev 158 Rev 160
Line 1069... Line 1069...
1069
	if ( !filename.empty() ) filename += "/";
1069
	if ( !filename.empty() ) filename += "/";
1070
 
1070
 
1071
	if ( (IsPatch()) && (pFile->fileType() == FILETYPE_MOD) )
1071
	if ( (IsPatch()) && (pFile->fileType() == FILETYPE_MOD) )
1072
		pFile->SetDir ( CyString("Patch") );
1072
		pFile->SetDir ( CyString("Patch") );
1073
 
1073
 
1074
	if ( pFile->IsInMod() )
1074
	if ( pFile->isInMod() )
1075
	{
1075
	{
1076
		if ( bEnabled )
1076
		if ( bEnabled )
1077
			pFile->setFilename(filename + pFile->GetInMod().ToString() + "::" + pFile->getNameDirectory(this));
1077
			pFile->setFilename(filename + pFile->getInMod() + "::" + pFile->getNameDirectory(this));
1078
		else
1078
		else
1079
			pFile->setFilename(filename + "PluginManager/DisabledFiles.cat::" + pFile->getNameDirectory(this));
1079
			pFile->setFilename(filename + "PluginManager/DisabledFiles.cat::" + pFile->getNameDirectory(this));
1080
	}
1080
	}
1081
	else
1081
	else
1082
		pFile->setFilename ( filename + pFile->getNameDirectory(this) );
1082
		pFile->setFilename ( filename + pFile->getNameDirectory(this) );
1083
 
1083
 
1084
	if ( !bEnabled )
1084
	if ( !bEnabled )
1085
	{
1085
	{
1086
		if ( !pFile->IsInMod() )
1086
		if ( !pFile->isInMod() )
1087
		{
1087
		{
1088
			if ( pFile->IsFakePatch() )
1088
			if ( pFile->IsFakePatch() )
1089
				pFile->setFilename ( filename + "PluginManager/Disabled/FakePatches/FakePatch_" + this->getNameValidFile() + "_" + this->author() + "_" + pFile->name() );
1089
				pFile->setFilename ( filename + "PluginManager/Disabled/FakePatches/FakePatch_" + this->getNameValidFile() + "_" + this->author() + "_" + pFile->name() );
1090
			else if ( pFile->isAutoTextFile() )
1090
			else if ( pFile->isAutoTextFile() )
1091
				pFile->setFilename ( filename + "PluginManager/Disabled/TextFiles/Text_" + this->getNameValidFile() + "_" + this->author() + "_" + pFile->name() );
1091
				pFile->setFilename ( filename + "PluginManager/Disabled/TextFiles/Text_" + this->getNameValidFile() + "_" + this->author() + "_" + pFile->name() );
Line 1131... Line 1131...
1131
	// if its disabled, rename it so its enabled
1131
	// if its disabled, rename it so its enabled
1132
	if ( ((pCheckFile->IsDisabled()) || (lastDir == "disabled") || (dir.lower().isin("/disabled/"))) && (bEnabled) )
1132
	if ( ((pCheckFile->IsDisabled()) || (lastDir == "disabled") || (dir.lower().isin("/disabled/"))) && (bEnabled) )
1133
	{
1133
	{
1134
		CLog::logf(CLog::Log_Install, 2, "Existing file, %s, is disabled, re-enabling it", pCheckFile->filePointer().c_str());
1134
		CLog::logf(CLog::Log_Install, 2, "Existing file, %s, is disabled, re-enabling it", pCheckFile->filePointer().c_str());
1135
		// first check if the directory exists
1135
		// first check if the directory exists
1136
		if ( pCheckFile->IsInMod() ) {
1136
		if ( pCheckFile->isInMod() ) {
1137
			CyString tofile = pCheckFile->filePointer().token("::", 2);
1137
			CyString tofile = pCheckFile->filePointer().token("::", 2);
1138
 
1138
 
1139
			CCatFile tocat;
1139
			CCatFile tocat;
1140
			int err = tocat.open(fit->filePointer().token("::", 1), "", CATREAD_CATDECRYPT, true);
1140
			int err = tocat.open(fit->filePointer().token("::", 1), "", CATREAD_CATDECRYPT, true);
1141
			if ( (err == CATERR_NONE) || (err == CATERR_CREATED) ) {
1141
			if ( (err == CATERR_NONE) || (err == CATERR_CREATED) ) {
Line 1150... Line 1150...
1150
				CLog::logf(CLog::Log_Install, 2, "Removing file from existing mod, %s::%s", pCheckFile->filePointer().token("::", 1).c_str(), tofile.c_str());
1150
				CLog::logf(CLog::Log_Install, 2, "Removing file from existing mod, %s::%s", pCheckFile->filePointer().token("::", 1).c_str(), tofile.c_str());
1151
			}
1151
			}
1152
 
1152
 
1153
			CLog::logf(CLog::Log_Install, 1, "Adjusting existing file name %s => %s", pCheckFile->filePointer().c_str(), fit->filePointer().c_str());
1153
			CLog::logf(CLog::Log_Install, 1, "Adjusting existing file name %s => %s", pCheckFile->filePointer().c_str(), fit->filePointer().c_str());
1154
			pCheckFile->SetFilename ( fit->GetFilePointer() );
1154
			pCheckFile->SetFilename ( fit->GetFilePointer() );
1155
			CLog::logf(CLog::Log_Install, 2, "Adjusting In Mod setting, %s => %s", pCheckFile->GetInMod().c_str(), fit->GetInMod().c_str());
1155
			CLog::logf(CLog::Log_Install, 2, "Adjusting In Mod setting, %s => %s", pCheckFile->getInMod().c_str(), fit->getInMod().c_str());
1156
			pCheckFile->SetInMod(fit->GetInMod());
1156
			pCheckFile->setInMod(fit->getInMod());
1157
		}
1157
		}
1158
		else {
1158
		else {
1159
			CyString to = pCheckFile->GetDirectory(this);
1159
			Utils::String to = pCheckFile->getDirectory(this);
1160
			CDirIO Dir(sDestination);
1160
			CDirIO Dir(sDestination);
1161
			if ( !Dir.exists(to.ToString()) ) {
1161
			if ( !Dir.exists(to) ) {
1162
				if ( !Dir.Create ( to ) ) {
1162
				if ( !Dir.create ( to ) ) {
1163
					if ( errorStr )	errorStr->PushBack(to, ERRORLOG_OLD(SPKINSTALL_CREATEDIRECTORY_FAIL));
1163
					if ( errorStr )	errorStr->PushBack(CyString(to), ERRORLOG_OLD(SPKINSTALL_CREATEDIRECTORY_FAIL));
1164
					return false;
1164
					return false;
1165
				}
1165
				}
1166
				if ( errorStr )	errorStr->PushBack(to, ERRORLOG_OLD(SPKINSTALL_CREATEDIRECTORY));
1166
				if ( errorStr )	errorStr->PushBack(CyString(to), ERRORLOG_OLD(SPKINSTALL_CREATEDIRECTORY));
1167
			}
1167
			}
1168
 
1168
 
1169
			CyString destfile = CyString(sDestination) + "/" + pCheckFile->GetNameDirectory(this);
1169
			CyString destfile = CyString(sDestination) + "/" + pCheckFile->GetNameDirectory(this);
1170
			if ( CFileIO(destfile).ExistsOld() ) CFileIO::Remove(destfile.ToString());
1170
			if ( CFileIO(destfile).ExistsOld() ) CFileIO::Remove(destfile.ToString());
1171
			CLog::logf(CLog::Log_Install, 1, "Adjusting existing filename, %s => %s", pCheckFile->GetFilePointer().c_str(), destfile.c_str());
1171
			CLog::logf(CLog::Log_Install, 1, "Adjusting existing filename, %s => %s", pCheckFile->GetFilePointer().c_str(), destfile.c_str());
Line 1186... Line 1186...
1186
	if ( !sTo.contains( "::" ) )
1186
	if ( !sTo.contains( "::" ) )
1187
	{
1187
	{
1188
		if ( !Dir.exists(sTo) )
1188
		if ( !Dir.exists(sTo) )
1189
		{
1189
		{
1190
			CLog::logf(CLog::Log_Install, 2, "Creating directory to install file into, %s", sTo.c_str());
1190
			CLog::logf(CLog::Log_Install, 2, "Creating directory to install file into, %s", sTo.c_str());
1191
			if ( !Dir.Create(sTo) )
1191
			if ( !Dir.create(sTo) )
1192
			{
1192
			{
1193
				if ( errorStr )
1193
				if ( errorStr )
1194
					errorStr->PushBack(CyString(sTo), ERRORLOG_OLD(SPKINSTALL_CREATEDIRECTORY_FAIL));
1194
					errorStr->PushBack(CyString(sTo), ERRORLOG_OLD(SPKINSTALL_CREATEDIRECTORY_FAIL));
1195
				return false;
1195
				return false;
1196
			}
1196
			}
Line 1235... Line 1235...
1235
		switch(pFile->GetFileType())
1235
		switch(pFile->GetFileType())
1236
		{
1236
		{
1237
			case FILETYPE_SCRIPT:
1237
			case FILETYPE_SCRIPT:
1238
			case FILETYPE_UNINSTALL:
1238
			case FILETYPE_UNINSTALL:
1239
				CLog::log(CLog::Log_Install, 2, "Updating file signature");
1239
				CLog::log(CLog::Log_Install, 2, "Updating file signature");
1240
				pFile->UpdateSignature();
1240
				pFile->updateSignature();
1241
				break;
1241
				break;
1242
		}
1242
		}
1243
	}
1243
	}
1244
}
1244
}
1245
 
1245
 
Line 1302... Line 1302...
1302
			{
1302
			{
1303
				// if the file is not enabled, we need to check for any that might be enabled
1303
				// if the file is not enabled, we need to check for any that might be enabled
1304
				if ( !fileEnabled ) //_install_checkDisabled(cFile, destdir, errorStr);
1304
				if ( !fileEnabled ) //_install_checkDisabled(cFile, destdir, errorStr);
1305
				{
1305
				{
1306
					//TODO: check what this is actually doing
1306
					//TODO: check what this is actually doing
1307
					if ( !cFile->GetUsed() )
1307
					if ( !cFile->getUsed() )
1308
					{
1308
					{
1309
						CFileIO rFile(cFile->GetFilePointer());
1309
						CFileIO rFile(cFile->filePointer());
1310
						if ( rFile.exists() )
1310
						if ( rFile.exists() )
1311
						{
1311
						{
1312
							if ( errorStr )
1312
							if ( errorStr )
1313
							{
1313
							{
1314
								if ( rFile.remove() )
1314
								if ( rFile.remove() )
1315
									errorStr->PushBack(cFile->GetFilePointer().Remove(destdir), ERRORLOG_OLD(SPKINSTALL_DELETEFILE));
1315
									errorStr->PushBack(cFile->GetFilePointer().Remove(destdir), ERRORLOG_OLD(SPKINSTALL_DELETEFILE));
1316
								else
1316
								else
1317
									errorStr->PushBack(cFile->GetFilePointer().Remove(destdir), ERRORLOG_OLD(SPKINSTALL_DELETEFILE_FAIL));
1317
									errorStr->PushBack(cFile->GetFilePointer().Remove(destdir), ERRORLOG_OLD(SPKINSTALL_DELETEFILE_FAIL));
1318
							}
1318
							}
1319
						}
1319
						}
1320
						cFile->SetFilename(fit->GetFilePointer());
1320
						cFile->setFilename(fit->filePointer());
1321
						cFile->SetDisabled(true);
1321
						cFile->SetDisabled(true);
1322
					}
1322
					}
1323
					else
1323
					else
1324
					{
1324
					{
1325
						fit->SetFullDir ( CyString(sInstallDir) + fit->GetDirectory(this) );
1325
						fit->setFullDir(sInstallDir + fit->getDirectory(this));
1326
						fit->SetDisabled(false);
1326
						fit->SetDisabled(false);
1327
					}
1327
					}
1328
				}
1328
				}
1329
				// move it to enabled
1329
				// move it to enabled
1330
				else {
1330
				else {
Line 1353... Line 1353...
1353
					continue;
1353
					continue;
1354
				}
1354
				}
1355
 
1355
 
1356
				int err = 1;
1356
				int err = 1;
1357
				_sLastError = to;
1357
				_sLastError = to;
1358
				if ( !fit->GetTempFile ().Empty() )	err = rename ( fit->GetTempFile().c_str(), to.c_str() );
1358
				if ( !fit->getTempFile().empty())	err = rename ( fit->getTempFile().c_str(), to.c_str() );
1359
				if ( err ) {
1359
				if ( err ) {
1360
					bFailed = true;
1360
					bFailed = true;
1361
					continue;
1361
					continue;
1362
				}
1362
				}
1363
			}
1363
			}
Line 1507... Line 1507...
1507
	else if ( first.Compare("EaseOfUse:") )			this->setEaseOfUse(rest);
1507
	else if ( first.Compare("EaseOfUse:") )			this->setEaseOfUse(rest);
1508
	else if ( first.Compare("Recommended:") )		this->setRecommended(rest);
1508
	else if ( first.Compare("Recommended:") )		this->setRecommended(rest);
1509
	else if ( first.Compare("NeededLibrary:") )
1509
	else if ( first.Compare("NeededLibrary:") )
1510
		this->AddNeededLibrary(rest.token("||", 1), rest.token("||", 2), rest.token("||", 3));
1510
		this->AddNeededLibrary(rest.token("||", 1), rest.token("||", 2), rest.token("||", 3));
1511
	else if ( first.Compare("FakePatchBefore:") )
1511
	else if ( first.Compare("FakePatchBefore:") )
1512
		this->AddFakePatchOrder(false, rest.token("||", 1), rest.token("||", 2));
1512
		this->addFakePatchOrder(false, rest.token("||", 1), rest.token("||", 2));
1513
	else if ( first.Compare("FakePatchAfter:") )
1513
	else if ( first.Compare("FakePatchAfter:") )
1514
		this->AddFakePatchOrder(true, rest.token("||", 1), rest.token("||", 2));
1514
		this->addFakePatchOrder(true, rest.token("||", 1), rest.token("||", 2));
1515
	else if ( first.Compare("ForumLink:") )			this->setForumLink(rest);
1515
	else if ( first.Compare("ForumLink:") )			this->setForumLink(rest);
1516
	else
1516
	else
1517
		return false;
1517
		return false;
1518
 
1518
 
1519
	return true;
1519
	return true;
Line 1979... Line 1979...
1979
	for ( CListNode<SNames> *nNode = m_lNames.Front(); nNode; nNode = nNode->next() )
1979
	for ( CListNode<SNames> *nNode = m_lNames.Front(); nNode; nNode = nNode->next() )
1980
		values += Utils::String("ScriptName: ") + (long)nNode->Data()->iLanguage + ":" + nNode->Data()->sName + "\n";
1980
		values += Utils::String("ScriptName: ") + (long)nNode->Data()->iLanguage + ":" + nNode->Data()->sName + "\n";
1981
 
1981
 
1982
	for ( CListNode<SNeededLibrary> *libNode = m_lNeededLibrarys.Front(); libNode; libNode = libNode->next() ) {
1982
	for ( CListNode<SNeededLibrary> *libNode = m_lNeededLibrarys.Front(); libNode; libNode = libNode->next() ) {
1983
		SNeededLibrary *l = libNode->Data();
1983
		SNeededLibrary *l = libNode->Data();
1984
		values += (CyString("NeededLibrary: ") + l->sName + "||" + l->sAuthor + "||" + l->sMinVersion + "\n").ToString();
1984
		values += "NeededLibrary: " + l->sName + "||" + l->sAuthor + "||" + l->sMinVersion + "\n";
1985
	}
1985
	}
1986
 
1986
 
1987
	for ( SStringList *fpbNode = m_lFakePatchBefore.Head(); fpbNode; fpbNode = fpbNode->;next )
1987
	for (auto itr = _lFakePatchBefore.begin(); itr != _lFakePatchBefore.end(); itr++)
1988
		values += (CyString(&quot;FakePatchBefore: ") + fpbNode->str + "||" + fpbNode->data + "\n").ToString();
1988
		values += &quot;FakePatchBefore: " + (*itr)->str + "||" + (*itr)->data + "\n";
1989
	for ( SStringList *fpaNode = m_lFakePatchAfter.Head(); fpaNode; fpaNode = fpaNode->;next )
1989
	for (auto itr = _lFakePatchAfter.begin(); itr != _lFakePatchAfter.end(); itr++)
1990
		values += (CyString(&quot;FakePatchAfter: ") + fpaNode->str + "||" + fpaNode->data + "\n").ToString();
1990
		values += &quot;FakePatchAfter: " + (*itr)->str + "||" + (*itr)->data + "\n";
1991
 
1991
 
1992
	values += Utils::String("PluginType: ") + (long)this->pluginType() + "\n";
1992
	values += Utils::String("PluginType: ") + (long)this->pluginType() + "\n";
1993
 
1993
 
1994
	return values;
1994
	return values;
1995
}
1995
}
Line 2386... Line 2386...
2386
	}
2386
	}
2387
 
2387
 
2388
	return NULL;
2388
	return NULL;
2389
}
2389
}
2390
 
2390
 
2391
void CBaseFile::RemoveFakePatchOrder(CyString scriptName, CyString author)
2391
void CBaseFile::removeFakePatchOrder(const Utils::String &scriptName, const Utils::String &author)
2392
{
2392
{
2393
	RemoveFakePatchOrder(true, scriptName, author);
2393
	removeFakePatchOrder(true, scriptName, author);
2394
	RemoveFakePatchOrder(false, scriptName, author);
2394
	removeFakePatchOrder(false, scriptName, author);
2395
}
2395
}
2396
void CBaseFile::RemoveFakePatchOrder(bool after, CyString scriptName, CyString author)
2396
void CBaseFile::removeFakePatchOrder(bool after, const Utils::String &scriptName, const Utils::String &author)
2397
{
2397
{
2398
	CyStringList *list;
2398
	Utils::CStringList *list;
2399
	if ( after )
2399
	if ( after )
2400
		list = &m_lFakePatchAfter;
2400
		list = &_lFakePatchAfter;
2401
	else
2401
	else
2402
		list = &m_lFakePatchBefore;
2402
		list = &_lFakePatchBefore;
2403
 
2403
 
2404
	for ( SStringList *str = list->Head(); str; str = str->next )
2404
	int found = list->findStringAndData(scriptName, author);
-
 
2405
	while (found != -1)
2405
	{
2406
	{
2406
		// already added
2407
		list->removeAt(found);
2407
		if ( str->str.Compare(scriptName) && str->data.Compare(author) )
2408
		found = list->findStringAndData(scriptName, author);
2408
			str->remove = true;
-
 
2409
	}
2409
	}
2410
 
-
 
2411
	list->RemoveMarked();
-
 
2412
}
2410
}
2413
 
2411
 
2414
void CBaseFile::AddFakePatchOrder(bool after, CyString scriptName, CyString author)
2412
void CBaseFile::addFakePatchOrder(bool after, const Utils::String &scriptName, const Utils::String &author)
2415
{
2413
{
2416
	CyStringList *list;
2414
	Utils::CStringList *list;
2417
	if ( after )
2415
	if ( after )
2418
		list = &m_lFakePatchAfter;
2416
		list = &_lFakePatchAfter;
2419
	else
2417
	else
2420
		list = &m_lFakePatchBefore;
2418
		list = &_lFakePatchBefore;
2421
 
2419
 
2422
	// check if the package already exists
2420
	// check if the package already exists
2423
	for ( SStringList *str = list->Head(); str; str = str->next )
2421
	if (!list->containsStringAndData(scriptName, author))
2424
	{
2422
	{
2425
		// already added
2423
		// cant have it on both list
2426
		if ( str->str.Compare(scriptName) && str->data.Compare(author) )
2424
		removeFakePatchOrder(!after, scriptName, author);
-
 
2425
 
2427
			return;
2426
		list->pushBack(scriptName, author);
2428
	}
2427
	}
2429
 
-
 
2430
	// cant have it on both list
-
 
2431
	RemoveFakePatchOrder(!after, scriptName, author);
-
 
2432
 
-
 
2433
	list->PushBack(scriptName, author);
-
 
2434
}
2428
}
2435
void CBaseFile::AddNeededLibrary(const Utils::String &scriptName, const Utils::String &author, const Utils::String &minVersion)
2429
void CBaseFile::AddNeededLibrary(const Utils::String &scriptName, const Utils::String &author, const Utils::String &minVersion)
2436
{
2430
{
2437
	SNeededLibrary *l = this->FindPackageNeeded(scriptName, author);
2431
	SNeededLibrary *l = this->FindPackageNeeded(scriptName, author);
2438
	if ( !l )
2432
	if ( !l )
Line 2928... Line 2922...
2928
	}
2922
	}
2929
	else if (sFirst.Compare("Icon"))
2923
	else if (sFirst.Compare("Icon"))
2930
	{
2924
	{
2931
		C_File *icon = new C_File(sRest.c_str());
2925
		C_File *icon = new C_File(sRest.c_str());
2932
		if (icon->ReadFromFile())
2926
		if (icon->ReadFromFile())
2933
			this->SetIcon(icon, CFileIO(sRest).GetFileExtension());
2927
			this->SetIcon(icon, CFileIO(sRest).extension());
2934
	}
2928
	}
2935
	else if (sFirst.Compare("CombineGameFiles"))
2929
	else if (sFirst.Compare("CombineGameFiles"))
2936
		_bCombineFiles = sRest.Compare("true") || sRest.Compare("yes") || sRest.toInt();
2930
		_bCombineFiles = sRest.Compare("true") || sRest.Compare("yes") || sRest.toInt();
2937
	else if (sFirst.Compare("UpdateFile"))
2931
	else if (sFirst.Compare("UpdateFile"))
2938
		this->createUpdateFile(sRest);
2932
		this->createUpdateFile(sRest);
Line 3050... Line 3044...
3050
 
3044
 
3051
	// wild cards
3045
	// wild cards
3052
	if ( rest.containsAny("*?") )
3046
	if ( rest.containsAny("*?") )
3053
	{
3047
	{
3054
		CDirIO Dir(CFileIO(rest).dir());
3048
		CDirIO Dir(CFileIO(rest).dir());
3055
		CyStringList *dirList = Dir.DirList();
3049
		Utils::CStringList dirList;
3056
		if ( dirList )
3050
		if(Dir.dirList(dirList))
3057
		{
3051
		{
3058
			for ( SStringList *strNode = dirList->Head(); strNode; strNode = strNode->;next )
3052
			for(auto itr = dirList.begin(); itr != dirList.end(); itr++)
3059
			{
3053
			{
3060
				Utils::String file = Dir.file(strNode->str.ToString());
3054
				Utils::String file = Dir.file((*itr)->str);
3061
				if (file.match(rest))
3055
				if (file.match(rest))
3062
				{
3056
				{
3063
					int addGame = game;
3057
					int addGame = game;
3064
					// check if the file exists in the subdirectory too, if it does, add for each game
3058
					// check if the file exists in the subdirectory too, if it does, add for each game
3065
					if ( game == GAME_ALL && !sMainGame.empty() && !otherGames.empty() ) {
3059
					if ( game == GAME_ALL && !sMainGame.empty() && !otherGames.empty() ) {
Line 3074... Line 3068...
3074
								if ( newfile ) newfile->SetShared(shared);
3068
								if ( newfile ) newfile->SetShared(shared);
3075
							}
3069
							}
3076
						}
3070
						}
3077
					}
3071
					}
3078
 
3072
 
3079
					C_File *newfile = this->appendFile(file, filetype, addGame, dir);
3073
					C_File *newfile = this->appendFile(file, filetype, addGame, packed, dir);
3080
					if (newfile && progress)
3074
					if (newfile && progress)
3081
						progress->UpdateFile(newfile);
3075
						progress->UpdateFile(newfile);
3082
					if ( newfile )
3076
					if ( newfile )
3083
						newfile->SetShared(shared);
3077
						newfile->SetShared(shared);
3084
				}
3078
				}
3085
			}
3079
			}
3086
			delete dirList;
-
 
3087
		}
3080
		}
3088
	}
3081
	}
3089
	else
3082
	else
3090
	{
3083
	{
3091
		unsigned int addGame = game;
3084
		unsigned int addGame = game;