Subversion Repositories spk

Rev

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

Rev 128 Rev 129
Line 410... Line 410...
410
 
410
 
411
	return true;
411
	return true;
412
}
412
}
413
 
413
 
414
 
414
 
415
void CBaseFile::RemoveAllFiles ( int type, int game )
415
void CBaseFile::removeAllFiles(FileType type, int game)
416
{
416
{
417
	if ( m_lFiles.empty() )
417
	if ( m_lFiles.empty() )
418
		return;
418
		return;
419
 
419
 
420
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
420
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
421
	{
421
	{
-
 
422
		if (game == 0 && node->Data()->game() && node->Data()->game() != GAME_ALLNEW)
-
 
423
			continue;
422
		if ( game > -1 ) {
424
		if ( game > -1 )
-
 
425
		{
-
 
426
			unsigned int fileGame = node->Data()->game() & ~GAME_ALLNEW;
423
			if ( node->Data()->GetGame() != game )
427
			if (fileGame != (1 << game))
-
 
428
			{
-
 
429
				// just remove the game from file
-
 
430
				if (fileGame & (1 << game))
-
 
431
					node->Data()->setGame(node->Data()->game() & ~(1 << game));
424
				continue;
432
				continue;
-
 
433
			}
425
		}
434
		}
426
		if ( type == -1 || node->Data()->GetFileType() == type )
435
		if ( type == FILETYPE_UNKNOWN || node->Data()->GetFileType() == type )
427
			node->DeleteData();
436
			node->DeleteData();
428
	}
437
	}
429
 
438
 
430
	m_lFiles.RemoveEmpty();
439
	m_lFiles.RemoveEmpty();
431
 
440
 
Line 1006... Line 1015...
1006
				pFile->SetFullDir ( filename + "PluginManager/Disabled/" + pFile->GetDirectory(this) );
1015
				pFile->SetFullDir ( filename + "PluginManager/Disabled/" + pFile->GetDirectory(this) );
1007
		}
1016
		}
1008
		pFile->SetDisabled(true);
1017
		pFile->SetDisabled(true);
1009
	}
1018
	}
1010
 
1019
 
1011
	CLog::logf(CLog::Log_Install, 2, "Adjusting the file pointer to correct install destintation, %s", pFile->GetFilePointer().c_str());
1020
	CLog::logf(CLog::Log_Install, 2, "Adjusting the file pointer to correct install destintation, %s", pFile->filePointer().c_str());
1012
 
1021
 
1013
	return filename.ToString();
1022
	return filename.ToString();
1014
}
1023
}
1015
 
1024
 
1016
C_File *CBaseFile::_install_checkFile(C_File *pFile, CyStringList *errorStr, bool *bDoFile, CLinkList<C_File> *pFileList)
1025
C_File *CBaseFile::_install_checkFile(C_File *pFile, CyStringList *errorStr, bool *bDoFile, CLinkList<C_File> *pFileList)
Line 1050... Line 1059...
1050
			CyString tofile = pCheckFile->filePointer().token("::", 2);
1059
			CyString tofile = pCheckFile->filePointer().token("::", 2);
1051
 
1060
 
1052
			CCatFile tocat;
1061
			CCatFile tocat;
1053
			int err = tocat.open(fit->filePointer().token("::", 1), "", CATREAD_CATDECRYPT, true);
1062
			int err = tocat.open(fit->filePointer().token("::", 1), "", CATREAD_CATDECRYPT, true);
1054
			if ( (err == CATERR_NONE) || (err == CATERR_CREATED) ) {
1063
			if ( (err == CATERR_NONE) || (err == CATERR_CREATED) ) {
1055
				tocat.AppendFile(pCheckFile->GetFilePointer().ToString(), tofile.ToString());
1064
				tocat.AppendFile(pCheckFile->filePointer(), tofile.ToString());
1056
				CLog::logf(CLog::Log_Install, 2, "Adding existing file into new mod File, %s => %s", fit->filePointer().token("::", 1).c_str(), tofile.c_str());
1065
				CLog::logf(CLog::Log_Install, 2, "Adding existing file into new mod File, %s => %s", fit->filePointer().token("::", 1).c_str(), tofile.c_str());
1057
			}
1066
			}
1058
 
1067
 
1059
			CCatFile fromcat;
1068
			CCatFile fromcat;
1060
			err = fromcat.open(pCheckFile->filePointer().token("::", 1), "", CATREAD_CATDECRYPT, false);
1069
			err = fromcat.open(pCheckFile->filePointer().token("::", 1), "", CATREAD_CATDECRYPT, false);
Line 1110... Line 1119...
1110
			if ( errorStr )
1119
			if ( errorStr )
1111
				errorStr->PushBack(CyString(sTo), ERRORLOG(SPKINSTALL_CREATEDIRECTORY));
1120
				errorStr->PushBack(CyString(sTo), ERRORLOG(SPKINSTALL_CREATEDIRECTORY));
1112
		}
1121
		}
1113
	}
1122
	}
1114
	else {
1123
	else {
1115
		CLog::logf(CLog::Log_Install, 2, "Adjusting file extension for file in mod, %s => %s", pFile->GetFilePointer().c_str(), CCatFile::PckChangeExtension(pFile->GetFilePointer().ToString()).c_str());
1124
		CLog::logf(CLog::Log_Install, 2, "Adjusting file extension for file in mod, %s => %s", pFile->filePointer().c_str(), CCatFile::PckChangeExtension(pFile->filePointer()).c_str());
1116
		pFile->SetFilename(CCatFile::PckChangeExtension(pFile->GetFilePointer().ToString()));
1125
		pFile->SetFilename(CCatFile::PckChangeExtension(pFile->filePointer()));
1117
	}
1126
	}
1118
 
1127
 
1119
	return true;
1128
	return true;
1120
}
1129
}
1121
 
1130
 
Line 1129... Line 1138...
1129
		sInstalledFile = pFile->GetFilePointer().Remove(sDestination);
1138
		sInstalledFile = pFile->GetFilePointer().Remove(sDestination);
1130
		if ( sInstalledFile[0] == '/' || sInstalledFile[0] == '\\' )
1139
		if ( sInstalledFile[0] == '/' || sInstalledFile[0] == '\\' )
1131
			sInstalledFile.Erase(0, 1);
1140
			sInstalledFile.Erase(0, 1);
1132
	}
1141
	}
1133
 
1142
 
1134
	if ( !pFile->WriteFilePointer() )
1143
	if ( !pFile->writeFilePointer() )
1135
	{
1144
	{
1136
		CLog::log(CLog::Log_Install, 1, "Failed to write the file");
1145
		CLog::log(CLog::Log_Install, 1, "Failed to write the file");
1137
		if ( errorStr )
1146
		if ( errorStr )
1138
			errorStr->PushBack(sInstalledFile, ERRORLOG(SPKINSTALL_WRITEFILE_FAIL));
1147
			errorStr->PushBack(sInstalledFile, ERRORLOG(SPKINSTALL_WRITEFILE_FAIL));
1139
	}
1148
	}
Line 1175... Line 1184...
1175
		// start the install process, check if we need to the file enabled or disabled
1184
		// start the install process, check if we need to the file enabled or disabled
1176
		CLog::logf(CLog::Log_Install, 1, "Preparing to install file: %s", fit->GetNameDirectory(this).c_str());
1185
		CLog::logf(CLog::Log_Install, 1, "Preparing to install file: %s", fit->GetNameDirectory(this).c_str());
1177
		bool fileEnabled = _install_setEnabled(enabled, fit);
1186
		bool fileEnabled = _install_setEnabled(enabled, fit);
1178
 
1187
 
1179
		// check if the file is for the correct game version
1188
		// check if the file is for the correct game version
1180
		if ( fit->GetGame() && packages->GetGame() ) {
1189
		if ( fit->game() && packages->GetGame() && fit->game() != GAME_ALLNEW) {
1181
			if ( fit->GetGame() != packages->GetGame() ) {
1190
			if(!(fit->game() & (1 << packages->GetGame())))
-
 
1191
			{
1182
				CLog::logf(CLog::Log_Install, 1, "File didn't match game version, skipping, %d != %d", fit->GetGame(), packages->GetGame());
1192
				CLog::logf(CLog::Log_Install, 1, "File didn't match game version, skipping, %d != %d", fit->game(), packages->GetGame());
1183
				continue;
1193
				continue;
1184
			}
1194
			}
1185
		}
1195
		}
1186
 
1196
 
1187
		// update the progress display to show we are processing this file
1197
		// update the progress display to show we are processing this file
Line 2065... Line 2075...
2065
					return true;
2075
					return true;
2066
			}
2076
			}
2067
			return false;
2077
			return false;
2068
		}
2078
		}
2069
 
2079
 
2070
		if ( !file->WriteToDir ( dir, this, includedir, NullString, data, len ) )
2080
		if ( !file->writeToDir(dir.ToString(), this, includedir, Utils::String::Null(), data, len) )
2071
			return false;
2081
			return false;
2072
 
2082
 
2073
		return true;
2083
		return true;
2074
 
2084
 
2075
	}
2085
	}
Line 2089... Line 2099...
2089
	// get the file pointer
2099
	// get the file pointer
2090
	C_File *file = m_lFiles.Get ( filenum );
2100
	C_File *file = m_lFiles.Get ( filenum );
2091
	return ExtractFile ( file, dir, includedir, progress );
2101
	return ExtractFile ( file, dir, includedir, progress );
2092
}
2102
}
2093
 
2103
 
2094
 
-
 
2095
 
-
 
2096
bool CBaseFile::ExtractAll ( CyString dir, int game, bool includedir, CProgressInfo *progress )
2104
bool CBaseFile::extractAll(const Utils::String &dir, int game, const Utils::CStringList &gameAddons, bool includedir, CProgressInfo *progress)
2097
{
2105
{
2098
	// no file to read from
2106
	// no file to read from
2099
	if ( this->filename().empty() )
2107
	if (this->filename().empty())
2100
		return false;
2108
		return false;
2101
 
2109
 
2102
	// now open the file
2110
	// now open the file
2103
	CFileIO *File = _startRead();
2111
	CFileIO *File = _startRead();
2104
	if ( !File ) return false;
2112
	if (!File) return false;
2105
 
2113
 
2106
	// now were in the file section
2114
	// now were in the file section
2107
	// skip past each one
2115
	// skip past each one
2108
	if ( m_pIconFile ) File->seek(4 + m_pIconFile->GetDataSize ());
2116
	if (m_pIconFile) File->seek(4 + m_pIconFile->GetDataSize());
2109
 
-
 
2110
	CDirIO Dir(dir);
-
 
2111
 
2117
 
2112
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() ) {
2118
	for (CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next()) {
2113
		C_File *fit = node->Data();
2119
		C_File *fit = node->Data();
2114
 
2120
 
2115
		if ( progress )	progress->UpdateFile ( fit );
2121
		if (progress)	progress->UpdateFile(fit);
2116
 
2122
 
2117
		if ( (!fit->GetDataSize ()) || (!fit->GetData()) ) {
2123
		if ((!fit->GetDataSize()) || (!fit->GetData())) {
2118
			if ( !fit->readFromFile(*File, fit->GetDataSize()) ) return false;
2124
			if (!fit->readFromFile(*File, fit->GetDataSize())) return false;
2119
		}
2125
		}
2120
		else
2126
		else
2121
			File->seek(fit->GetDataSize());
2127
			File->seek(fit->GetDataSize());
2122
 
2128
 
-
 
2129
		if (game && !fit->isForGame(game))
-
 
2130
			continue;
-
 
2131
 
2123
		if ( game ) {
2132
		CDirIO Dir(dir);
-
 
2133
		Utils::String addonDir;
-
 
2134
		if (fit->isFileInAddon())
-
 
2135
		{
-
 
2136
			int addonGame = fit->getForSingleGame();
2124
			if ( fit->GetGame() && fit->GetGame() != game )
2137
			if (!addonGame) addonGame = game;
-
 
2138
 
2125
				continue;
2139
			if (addonGame > 0)
-
 
2140
				addonDir = gameAddons.findString(Utils::String::Number(addonGame));
2126
		}
2141
		}
2127
 
2142
 
-
 
2143
		if (!addonDir.empty())
-
 
2144
			Dir.cd(addonDir);
-
 
2145
 
2128
		// create directory first
2146
		// create directory first
2129
		Dir.Create(fit->GetDirectory(this));
2147
		Dir.create(fit->getDirectory(this));
2130
 
2148
 
2131
		long size = 0;
2149
		long size = 0;
2132
		unsigned char *data = fit->UncompressData (&size, progress);
2150
		unsigned char *data = fit->UncompressData(&size, progress);
2133
		if ( (!data) && (fit->GetCompressionType() == SPKCOMPRESS_7ZIP) ) {
2151
		if ((!data) && (fit->GetCompressionType() == SPKCOMPRESS_7ZIP)) {
2134
			if ( !fit->UncompressToFile ( dir, this, includedir, progress ) ) return false;
2152
			if (!fit->UncompressToFile(Dir.dir(), this, includedir, progress)) return false;
2135
		}
2153
		}
2136
		else if ( (!data) || (!fit->WriteToDir ( dir, this, includedir, NullString, data, size )) ) return false;
2154
		else if ((!data) || (!fit->writeToDir(Dir.dir(), this, includedir, Utils::String::Null(), data, size))) return false;
2137
	}
2155
	}
2138
 
2156
 
2139
	delete File;
2157
	delete File;
2140
	return true;
2158
	return true;
2141
}
2159
}
2142
 
2160
 
2143
 
2161
 
2144
 
2162
 
2145
 
-
 
2146
bool CBaseFile::UpdateSigned (bool updateFiles)
2163
bool CBaseFile::UpdateSigned (bool updateFiles)
2147
{
2164
{
2148
	m_bSigned = true;
2165
	m_bSigned = true;
2149
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
2166
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
2150
	{
2167
	{