Subversion Repositories spk

Rev

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

Rev 131 Rev 134
Line 215... Line 215...
215
	name.removeChar('?');
215
	name.removeChar('?');
216
	name.removeChar('"');
216
	name.removeChar('"');
217
	name.removeChar('<');
217
	name.removeChar('<');
218
	name.removeChar('>');
218
	name.removeChar('>');
219
	name.removeChar('|');
219
	name.removeChar('|');
220
	return name;
-
 
221
}
-
 
222
CyString CBaseFile::GetNameValidFile()
-
 
223
{
-
 
224
	CyString name = this->name();
-
 
225
	name.RemoveChar ( ':' );
-
 
226
	name.RemoveChar ( '/' );
-
 
227
	name.RemoveChar ( '\\' );
-
 
228
	name.RemoveChar ( '*' );
-
 
229
	name.RemoveChar ( '?' );
-
 
230
	name.RemoveChar ( '"' );
-
 
231
	name.RemoveChar ( '<' );
-
 
232
	name.RemoveChar ( '>' );
-
 
233
	name.RemoveChar ( '|' );
-
 
234
	return name;
220
	return name;
235
}
221
}
236
 
222
 
237
void CBaseFile::SwitchFilePointer(C_File *oldFile, C_File *newFile)
223
void CBaseFile::SwitchFilePointer(C_File *oldFile, C_File *newFile)
238
{
224
{
239
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
225
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
240
	{
226
	{
241
		C_File *f = node->Data();
227
		C_File *f = node->Data();
242
		if ( f == oldFile )
228
		if ( f == oldFile )
243
		{
229
		{
244
			node->ChangeData(newFile);
230
			node->ChangeData(newFile);
245
			break;
231
			break;
246
		}
232
		}
247
	}
233
	}
248
}
234
}
249
 
235
 
250
bool CBaseFile::AnyFileType ( int type )
236
bool CBaseFile::AnyFileType ( int type )
251
{
237
{
252
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
238
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
253
	{
239
	{
254
		C_File *f = node->Data();
240
		C_File *f = node->Data();
255
		if ( f->GetFileType() == type )
241
		if ( f->GetFileType() == type )
256
			return true;
242
			return true;
257
	}
243
	}
258
 
244
 
259
	return false;
245
	return false;
260
}
246
}
261
 
247
 
262
void CBaseFile::AddFile ( C_File *file )
248
void CBaseFile::AddFile ( C_File *file )
263
{
249
{
264
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
250
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
265
	{
251
	{
266
		C_File *f = node->Data();
252
		C_File *f = node->Data();
267
		if ( f->fileType() != file->fileType() )
253
		if ( f->fileType() != file->fileType() )
268
			continue;
254
			continue;
269
		if ( f->name() != file->name () )
255
		if ( f->name() != file->name () )
270
			continue;
256
			continue;
271
		if ( f->GetDir() != file->GetDir() )
257
		if ( f->GetDir() != file->GetDir() )
272
			continue;
258
			continue;
273
		if ( f->game() != file->game() )
259
		if ( f->game() != file->game() )
274
			continue;
260
			continue;
275
 
261
 
276
		m_lFiles.remove(node, true);
262
		m_lFiles.remove(node, true);
277
		break;
263
		break;
278
	}
264
	}
279
 
265
 
280
	_addFile(file);
266
	_addFile(file);
281
}
267
}
282
 
268
 
283
C_File *CBaseFile::AddFile(CyString file, CyString dir, int type, int game)
269
C_File *CBaseFile::AddFile(CyString file, CyString dir, int type, int game)
284
{
270
{
Line 297... Line 283...
297
		C_File *f = node->Data();
283
		C_File *f = node->Data();
298
		if ( f->fileType() != newfile->fileType() )
284
		if ( f->fileType() != newfile->fileType() )
299
			continue;
285
			continue;
300
		if ( f->name() != newfile->name () )
286
		if ( f->name() != newfile->name () )
301
			continue;
287
			continue;
302
		if ( f->GetDir() != newfile->GetDir() )
288
		if ( f->dir() != newfile->dir() )
303
			continue;
289
			continue;
304
		if (f->game() != newfile->game())
290
		if (f->game() != newfile->game())
305
		{
291
		{
306
			//same file, for different game, check if they are the same and combine them
292
			//same file, for different game, check if they are the same and combine them
307
			if (_bCombineFiles)
293
			if (_bCombineFiles)
Line 360... Line 346...
360
		}
346
		}
361
 
347
 
362
		// must already exist, delete this one
348
		// must already exist, delete this one
363
		m_lFiles.remove(node, true);
349
		m_lFiles.remove(node, true);
364
		break;
350
		break;
365
	}
351
	}
366
 
352
 
367
	_addFile(newfile);
353
	_addFile(newfile);
368
 
354
 
369
	return newfile;
355
	return newfile;
370
}
356
}
371
 
357
 
372
bool CBaseFile::AddFileNow ( CyString file, CyString dir, int type, CProgressInfo *progress )
358
bool CBaseFile::AddFileNow ( CyString file, CyString dir, int type, CProgressInfo *progress )
373
{
359
{
374
	C_File *f = AddFile ( file, dir, type );
360
	C_File *f = AddFile ( file, dir, type );
375
	if ( !f->ReadFromFile () )
361
	if ( !f->ReadFromFile () )
376
		return false;
362
		return false;
377
 
363
 
378
	// compress the file
364
	// compress the file
Line 389... Line 375...
389
	// read the file into memory
375
	// read the file into memory
390
	if ( newfile->ReadFromFile () )
376
	if ( newfile->ReadFromFile () )
391
	{
377
	{
392
		// now compress the file
378
		// now compress the file
393
		if ( newfile->CompressData ( m_SHeader2.iDataCompression, progress ) )
379
		if ( newfile->CompressData ( m_SHeader2.iDataCompression, progress ) )
394
			return newfile;
380
			return newfile;
395
	}
381
	}
396
	else if ( newfile->GetLastError() == SPKERR_MALLOC )
382
	else if ( newfile->GetLastError() == SPKERR_MALLOC )
397
	{
383
	{
398
		if ( newfile->CompressFile ( progress ) )
384
		if ( newfile->CompressFile ( progress ) )
399
			return newfile;
385
			return newfile;
Line 404... Line 390...
404
 
390
 
405
	return NULL;
391
	return NULL;
406
}
392
}
407
 
393
 
408
C_File *CBaseFile::FindFileAt ( int filetype, int pos )
394
C_File *CBaseFile::FindFileAt ( int filetype, int pos )
409
{
395
{
410
	int count = 0;
396
	int count = 0;
411
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
397
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
412
	{
398
	{
413
		C_File *file = node->Data();
399
		C_File *file = node->Data();
414
		if ( file->GetFileType() != filetype )
400
		if ( file->GetFileType() != filetype )
415
			continue;
401
			continue;
Line 492... Line 478...
492
		return;
478
		return;
493
 
479
 
494
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
480
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
495
	{
481
	{
496
		if (game == 0 && node->Data()->game() && node->Data()->game() != GAME_ALLNEW)
482
		if (game == 0 && node->Data()->game() && node->Data()->game() != GAME_ALLNEW)
497
			continue;
483
			continue;
498
		if ( game > -1 )
484
		if ( game > -1 )
499
		{
485
		{
500
			unsigned int fileGame = node->Data()->game() & ~GAME_ALLNEW;
486
			unsigned int fileGame = node->Data()->game() & ~GAME_ALLNEW;
501
			if (fileGame != (1 << game))
487
			if (fileGame != (1 << game))
502
			{
488
			{
Line 506... Line 492...
506
				continue;
492
				continue;
507
			}
493
			}
508
		}
494
		}
509
		if ( type == FILETYPE_UNKNOWN || node->Data()->GetFileType() == type )
495
		if ( type == FILETYPE_UNKNOWN || node->Data()->GetFileType() == type )
510
			node->DeleteData();
496
			node->DeleteData();
511
	}
497
	}
512
 
498
 
513
	m_lFiles.RemoveEmpty();
499
	m_lFiles.RemoveEmpty();
514
 
500
 
515
	_changed();
501
	_changed();
516
}
502
}
517
 
503
 
518
void CBaseFile::RecompressAllFiles ( int type, CProgressInfo *progress )
504
void CBaseFile::RecompressAllFiles ( int type, CProgressInfo *progress )
Line 530... Line 516...
530
			file->ReadFromFile();
516
			file->ReadFromFile();
531
 
517
 
532
		file->ChangeCompression ( type, progress );
518
		file->ChangeCompression ( type, progress );
533
	}
519
	}
534
}
520
}
535
 
521
 
536
void CBaseFile::CompressAllFiles ( int type, CProgressInfo *progress, CProgressInfo *overallProgress, int level )
522
void CBaseFile::CompressAllFiles ( int type, CProgressInfo *progress, CProgressInfo *overallProgress, int level )
537
{
523
{
538
	if ( overallProgress ) overallProgress->SetMax(m_lFiles.size());
524
	if ( overallProgress ) overallProgress->SetMax(m_lFiles.size());
539
 
525
 
540
	int iCount = 0;
526
	int iCount = 0;
541
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
527
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
542
	{
528
	{
543
		C_File *file = node->Data();
529
		C_File *file = node->Data();
544
		if ( progress )
530
		if ( progress )
545
			progress->UpdateFile(file);
531
			progress->UpdateFile(file);
546
 
532
 
Line 557... Line 543...
557
{
543
{
558
	int countFile = 0;
544
	int countFile = 0;
559
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
545
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
560
	{
546
	{
561
		C_File *fit = node->Data();
547
		C_File *fit = node->Data();
562
		if ( progress )
548
		if ( progress )
563
		{
549
		{
564
			progress->UpdateFile ( fit );
550
			progress->UpdateFile ( fit );
565
			progress->UpdateProgress(countFile++, m_lFiles.size());
551
			progress->UpdateProgress(countFile++, m_lFiles.size());
566
		}
552
		}
567
 
553
 
568
		bool uncomprToFile = false;
554
		bool uncomprToFile = false;
Line 580... Line 566...
580
						return false;
566
						return false;
581
					else
567
					else
582
					{
568
					{
583
						uncomprToFile = true;
569
						uncomprToFile = true;
584
						fit->SetFullDir("temp");
570
						fit->SetFullDir("temp");
585
					}
571
					}
586
				}
572
				}
587
 
573
 
588
				if (!uncomprToFile)
574
				if (!uncomprToFile)
589
					return false;
575
					return false;
590
			}
576
			}
Line 666... Line 652...
666
		if ( n->iLanguage == lang )
652
		if ( n->iLanguage == lang )
667
		{
653
		{
668
			m_lNames.RemoveCurrent();
654
			m_lNames.RemoveCurrent();
669
			delete n;
655
			delete n;
670
			_changed();
656
			_changed();
671
		}
657
		}
672
	}
658
	}
673
}
659
}
674
 
660
 
675
void CBaseFile::AddLanguageName ( int lang, const Utils::String &name )
661
void CBaseFile::AddLanguageName ( int lang, const Utils::String &name )
676
{
662
{
Line 927... Line 913...
927
 
913
 
928
	if ( (!m_pIconFile->GetData()) && (!m_pIconFile->Skip()) )
914
	if ( (!m_pIconFile->GetData()) && (!m_pIconFile->Skip()) )
929
		m_pIconFile->readFromFile(*File, m_pIconFile->GetDataSize());
915
		m_pIconFile->readFromFile(*File, m_pIconFile->GetDataSize());
930
	else
916
	else
931
		File->seek(4 + m_pIconFile->GetDataSize());
917
		File->seek(4 + m_pIconFile->GetDataSize());
932
 
918
 
933
	delete File;
919
	delete File;
934
}
920
}
935
 
921
 
936
void CBaseFile::_install_adjustFakePatches(CPackages *pPackages)
922
void CBaseFile::_install_adjustFakePatches(CPackages *pPackages)
937
{
923
{
938
	CyStringList lPatches;
924
	CyStringList lPatches;
939
	int startfake = pPackages->FindNextFakePatch();
925
	int startfake = pPackages->FindNextFakePatch();
940
 
926
 
Line 1008... Line 994...
1008
}
994
}
1009
 
995
 
1010
bool CBaseFile::_install_uncompress(C_File *fit, CProgressInfo *progress, CyStringList *errorStr, bool *uncomprToFile)
996
bool CBaseFile::_install_uncompress(C_File *fit, CProgressInfo *progress, CyStringList *errorStr, bool *uncomprToFile)
1011
{
997
{
1012
	*uncomprToFile = false;
998
	*uncomprToFile = false;
1013
	m_sLastError = fit->GetNameDirectory(this);
999
	_sLastError = fit->getNameDirectory(this);
1014
	m_iLastError = SPKERR_UNCOMPRESS;
1000
	_iLastError = SPKERR_UNCOMPRESS;
1015
 
1001
 
1016
	if ( !fit->UncompressData ( progress ) )
1002
	if ( !fit->UncompressData ( progress ) )
1017
	{
1003
	{
1018
		CLog::log(CLog::Log_Install, 2, "Failed to uncompress data, attempting file decompression");
1004
		CLog::log(CLog::Log_Install, 2, "Failed to uncompress data, attempting file decompression");
1019
		if ( fit->GetCompressionType() == SPKCOMPRESS_7ZIP )
1005
		if ( fit->GetCompressionType() == SPKCOMPRESS_7ZIP )
Line 1023... Line 1009...
1023
		}
1009
		}
1024
 
1010
 
1025
		if ( !uncomprToFile )
1011
		if ( !uncomprToFile )
1026
		{
1012
		{
1027
			if ( errorStr )
1013
			if ( errorStr )
1028
				errorStr->PushBack(m_sLastError, ERRORLOG(SPKINSTALL_UNCOMPRESS_FAIL));
1014
				errorStr->PushBack(CyString(_sLastError), ERRORLOG_OLD(SPKINSTALL_UNCOMPRESS_FAIL));
1029
			CLog::log(CLog::Log_Install, 1, "Unable to decompress file, skipping");
1015
			CLog::log(CLog::Log_Install, 1, "Unable to decompress file, skipping");
1030
			return false;
1016
			return false;
1031
		}
1017
		}
1032
	}
1018
	}
1033
	ClearError ();
1019
	ClearError ();
Line 1103... Line 1089...
1103
		C_File *cFile;
1089
		C_File *cFile;
1104
		for ( cFile = pFileList->First(); cFile; cFile = pFileList->Next() )
1090
		for ( cFile = pFileList->First(); cFile; cFile = pFileList->Next() )
1105
		{
1091
		{
1106
			if ( !cFile->MatchFile(pFile) ) continue;
1092
			if ( !cFile->MatchFile(pFile) ) continue;
1107
			if ( !m_bOverrideFiles && !cFile->CompareNew(pFile) ) {
1093
			if ( !m_bOverrideFiles && !cFile->CompareNew(pFile) ) {
1108
				if ( errorStr ) errorStr->PushBack(pFile->GetNameDirectory(this), ERRORLOG(SPKINSTALL_SKIPFILE));
1094
				if ( errorStr ) errorStr->PushBack(pFile->GetNameDirectory(this), ERRORLOG_OLD(SPKINSTALL_SKIPFILE));
1109
				CLog::log(CLog::Log_Install, 1, "Newer version of the file already installed, skipping");
1095
				CLog::log(CLog::Log_Install, 1, "Newer version of the file already installed, skipping");
1110
				*bDoFile = false;
1096
				*bDoFile = false;
1111
			}
1097
			}
1112
			break;
1098
			break;
1113
		}
1099
		}
Line 1154... Line 1140...
1154
		else {
1140
		else {
1155
			CyString to = pCheckFile->GetDirectory(this);
1141
			CyString to = pCheckFile->GetDirectory(this);
1156
			CDirIO Dir(sDestination);
1142
			CDirIO Dir(sDestination);
1157
			if ( !Dir.exists(to.ToString()) ) {
1143
			if ( !Dir.exists(to.ToString()) ) {
1158
				if ( !Dir.Create ( to ) ) {
1144
				if ( !Dir.Create ( to ) ) {
1159
					if ( errorStr )	errorStr->PushBack(to, ERRORLOG(SPKINSTALL_CREATEDIRECTORY_FAIL));
1145
					if ( errorStr )	errorStr->PushBack(to, ERRORLOG_OLD(SPKINSTALL_CREATEDIRECTORY_FAIL));
1160
					return false;
1146
					return false;
1161
				}
1147
				}
1162
				if ( errorStr )	errorStr->PushBack(to, ERRORLOG(SPKINSTALL_CREATEDIRECTORY));
1148
				if ( errorStr )	errorStr->PushBack(to, ERRORLOG_OLD(SPKINSTALL_CREATEDIRECTORY));
1163
			}
1149
			}
1164
 
1150
 
1165
			CyString destfile = CyString(sDestination) + "/" + pCheckFile->GetNameDirectory(this);
1151
			CyString destfile = CyString(sDestination) + "/" + pCheckFile->GetNameDirectory(this);
1166
			if ( CFileIO(destfile).ExistsOld() ) CFileIO::Remove(destfile.ToString());
1152
			if ( CFileIO(destfile).ExistsOld() ) CFileIO::Remove(destfile.ToString());
1167
			CLog::logf(CLog::Log_Install, 1, "Adjusting existing filename, %s => %s", pCheckFile->GetFilePointer().c_str(), destfile.c_str());
1153
			CLog::logf(CLog::Log_Install, 1, "Adjusting existing filename, %s => %s", pCheckFile->GetFilePointer().c_str(), destfile.c_str());
1168
			rename ( pCheckFile->GetFilePointer().c_str(), destfile.c_str() );
1154
			rename ( pCheckFile->GetFilePointer().c_str(), destfile.c_str() );
1169
			pCheckFile->SetFilename ( CyString(sDestination) + "/" + pCheckFile->GetNameDirectory(this) );
1155
			pCheckFile->SetFilename ( CyString(sDestination) + "/" + pCheckFile->GetNameDirectory(this) );
1170
		}
1156
		}
1171
		pCheckFile->SetDisabled(false);
1157
		pCheckFile->SetDisabled(false);
1172
 
1158
 
1173
		if ( errorStr ) errorStr->PushBack(pCheckFile->GetNameDirectory(this), ERRORLOG(SPKINSTALL_ENABLEFILE));
1159
		if ( errorStr ) errorStr->PushBack(pCheckFile->GetNameDirectory(this), ERRORLOG_OLD(SPKINSTALL_ENABLEFILE));
1174
	}
1160
	}
1175
 
1161
 
1176
	return true;
1162
	return true;
1177
}
1163
}
1178
 
1164
 
1179
bool CBaseFile::_install_createDirectory(CDirIO &Dir, const Utils::String &sTo, C_File *pFile, CyStringList *errorStr)
1165
bool CBaseFile::_install_createDirectory(CDirIO &Dir, const Utils::String &sTo, C_File *pFile, CyStringList *errorStr)
1180
{
1166
{
1181
	m_sLastError = sTo;
1167
	_sLastError = sTo;
1182
	if ( !sTo.isin ( "::" ) )
1168
	if ( !sTo.contains( "::" ) )
1183
	{
1169
	{
1184
		if ( !Dir.exists(sTo) )
1170
		if ( !Dir.exists(sTo) )
1185
		{
1171
		{
1186
			CLog::logf(CLog::Log_Install, 2, "Creating directory to install file into, %s", sTo.c_str());
1172
			CLog::logf(CLog::Log_Install, 2, "Creating directory to install file into, %s", sTo.c_str());
1187
			if ( !Dir.Create(sTo) )
1173
			if ( !Dir.Create(sTo) )
1188
			{
1174
			{
1189
				if ( errorStr )
1175
				if ( errorStr )
1190
					errorStr->PushBack(CyString(sTo), ERRORLOG(SPKINSTALL_CREATEDIRECTORY_FAIL));
1176
					errorStr->PushBack(CyString(sTo), ERRORLOG_OLD(SPKINSTALL_CREATEDIRECTORY_FAIL));
1191
				return false;
1177
				return false;
1192
			}
1178
			}
1193
			if ( errorStr )
1179
			if ( errorStr )
1194
				errorStr->PushBack(CyString(sTo), ERRORLOG(SPKINSTALL_CREATEDIRECTORY));
1180
				errorStr->PushBack(CyString(sTo), ERRORLOG_OLD(SPKINSTALL_CREATEDIRECTORY));
1195
		}
1181
		}
1196
	}
1182
	}
1197
	else {
1183
	else {
1198
		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());
1184
		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());
1199
		pFile->SetFilename(CCatFile::PckChangeExtension(pFile->filePointer()));
1185
		pFile->setFilename(CCatFile::PckChangeExtension(pFile->filePointer()));
1200
	}
1186
	}
1201
 
1187
 
1202
	return true;
1188
	return true;
1203
}
1189
}
1204
 
1190
 
1205
void CBaseFile::_install_writeFile(C_File *pFile, const Utils::String &sDestination, CyStringList *errorStr)
1191
void CBaseFile::_install_writeFile(C_File *pFile, const Utils::String &sDestination, CyStringList *errorStr)
1206
{
1192
{
1207
	m_iLastError = SPKERR_WRITEFILE;
1193
	_iLastError = SPKERR_WRITEFILE;
1208
	m_sLastError = pFile->GetFilePointer();
1194
	_sLastError = pFile->filePointer();
1209
	CyString sInstalledFile = pFile->GetNameDirectory(this);
1195
	Utils::String sInstalledFile = pFile->getNameDirectory(this);
1210
	if ( pFile->IsDisabled() )
1196
	if ( pFile->IsDisabled() )
1211
	{
1197
	{
1212
		sInstalledFile = pFile->GetFilePointer().Remove(sDestination);
1198
		sInstalledFile = pFile->filePointer().findRemove(sDestination);
1213
		if ( sInstalledFile[0] == '/' || sInstalledFile[0] == '\\' )
1199
		if ( sInstalledFile[0] == '/' || sInstalledFile[0] == '\\' )
1214
			sInstalledFile.Erase(0, 1);
1200
			sInstalledFile.erase(0, 1);
1215
	}
1201
	}
1216
 
1202
 
1217
	if ( !pFile->writeFilePointer() )
1203
	if ( !pFile->writeFilePointer() )
1218
	{
1204
	{
1219
		CLog::log(CLog::Log_Install, 1, "Failed to write the file");
1205
		CLog::log(CLog::Log_Install, 1, "Failed to write the file");
1220
		if ( errorStr )
1206
		if ( errorStr )
1221
			errorStr->PushBack(sInstalledFile, ERRORLOG(SPKINSTALL_WRITEFILE_FAIL));
1207
			errorStr->PushBack(CyString(sInstalledFile), ERRORLOG_OLD(SPKINSTALL_WRITEFILE_FAIL));
1222
	}
1208
	}
1223
	else
1209
	else
1224
	{
1210
	{
1225
		CLog::log(CLog::Log_Install, 1, "File written successfully");
1211
		CLog::log(CLog::Log_Install, 1, "File written successfully");
1226
		CLog::log(CLog::Log_Install, 2, "Checking signed status of the file");
1212
		CLog::log(CLog::Log_Install, 2, "Checking signed status of the file");
1227
		pFile->UpdateSigned();
1213
		pFile->UpdateSigned();
1228
		if ( errorStr )
1214
		if ( errorStr )
1229
			errorStr->PushBack(sInstalledFile, ERRORLOG(SPKINSTALL_WRITEFILE));
1215
			errorStr->PushBack(CyString(sInstalledFile), ERRORLOG_OLD(SPKINSTALL_WRITEFILE));
1230
 
1216
 
1231
		switch(pFile->GetFileType())
1217
		switch(pFile->GetFileType())
1232
		{
1218
		{
1233
			case FILETYPE_SCRIPT:
1219
			case FILETYPE_SCRIPT:
1234
			case FILETYPE_UNINSTALL:
1220
			case FILETYPE_UNINSTALL:
Line 1308... Line 1294...
1308
						if ( rFile.exists() )
1294
						if ( rFile.exists() )
1309
						{
1295
						{
1310
							if ( errorStr )
1296
							if ( errorStr )
1311
							{
1297
							{
1312
								if ( rFile.remove() )
1298
								if ( rFile.remove() )
1313
									errorStr->PushBack(cFile->GetFilePointer().Remove(destdir), ERRORLOG(SPKINSTALL_DELETEFILE));
1299
									errorStr->PushBack(cFile->GetFilePointer().Remove(destdir), ERRORLOG_OLD(SPKINSTALL_DELETEFILE));
1314
								else
1300
								else
1315
									errorStr->PushBack(cFile->GetFilePointer().Remove(destdir), ERRORLOG(SPKINSTALL_DELETEFILE_FAIL));
1301
									errorStr->PushBack(cFile->GetFilePointer().Remove(destdir), ERRORLOG_OLD(SPKINSTALL_DELETEFILE_FAIL));
1316
							}
1302
							}
1317
						}
1303
						}
1318
						cFile->SetFilename(fit->GetFilePointer());
1304
						cFile->SetFilename(fit->GetFilePointer());
1319
						cFile->SetDisabled(true);
1305
						cFile->SetDisabled(true);
1320
					}
1306
					}
Line 1340... Line 1326...
1340
		if ( dofile )
1326
		if ( dofile )
1341
		{
1327
		{
1342
			// uncompressed to file, rename and move
1328
			// uncompressed to file, rename and move
1343
			if ( uncomprToFile )
1329
			if ( uncomprToFile )
1344
			{
1330
			{
1345
				m_iLastError = SPKERR_WRITEFILE;
1331
				_iLastError = SPKERR_WRITEFILE;
1346
				CyString to = fit->GetDirectory(this);
1332
				Utils::String to = fit->getDirectory(this);
1347
				if ( !fileEnabled )	to = CyString("PluginManager/Disabled/") + to;
1333
				if ( !fileEnabled )	to = "PluginManager/Disabled/" + to;
1348
 
1334
 
1349
				if ( !_install_createDirectory(Dir, to.ToString(), fit, errorStr) ) {
1335
				if ( !_install_createDirectory(Dir, to, fit, errorStr) ) {
1350
					bFailed = true;
1336
					bFailed = true;
1351
					continue;
1337
					continue;
1352
				}
1338
				}
1353
 
1339
 
1354
				int err = 1;
1340
				int err = 1;
1355
				m_sLastError = to;
1341
				_sLastError = to;
1356
				if ( !fit->GetTempFile ().Empty() )	err = rename ( fit->GetTempFile().c_str(), to.c_str() );
1342
				if ( !fit->GetTempFile ().Empty() )	err = rename ( fit->GetTempFile().c_str(), to.c_str() );
1357
				if ( err ) {
1343
				if ( err ) {
1358
					bFailed = true;
1344
					bFailed = true;
1359
					continue;
1345
					continue;
1360
				}
1346
				}
Line 1366... Line 1352...
1366
				if ( (filelist) && (adjustPointer) ) {
1352
				if ( (filelist) && (adjustPointer) ) {
1367
					adjustPointer->CopyData(fit, false);
1353
					adjustPointer->CopyData(fit, false);
1368
					CLog::log(CLog::Log_Install, 2, "Copying data into existing file");
1354
					CLog::log(CLog::Log_Install, 2, "Copying data into existing file");
1369
				}
1355
				}
1370
 
1356
 
1371
				CyString fpointer = fit->GetFilePointer();
1357
				Utils::String fpointer = fit->filePointer();
1372
				m_iLastError = SPKERR_CREATEDIRECTORY;
1358
				_iLastError = SPKERR_CREATEDIRECTORY;
1373
				CyString dir = fit->GetFilePointer().GetToken ( "/", 1, fit->;GetFilePointer().NumToken("/") - 1 );
1359
				Utils::String dir = CFileIO(fit->;filePointer()).dir();
1374
 
1360
 
1375
				dir = dir.Remove(destdir);
1361
				dir = dir.findRemove(destdir.ToString());
1376
				if ( dir[0] == '/' || dir[0] == '\\' ) dir.Erase(0, 1);
1362
				if ( dir[0] == '/' || dir[0] == '\\' ) dir.erase(0, 1);
1377
 
1363
 
1378
				if ( !_install_createDirectory(Dir, dir.ToString(), fit, errorStr) ) {
1364
				if ( !_install_createDirectory(Dir, dir, fit, errorStr) ) {
1379
					bFailed = true;
1365
					bFailed = true;
1380
					continue;
1366
					continue;
1381
				}
1367
				}
1382
 
1368
 
1383
				_install_writeFile(fit, destdir.ToString(), errorStr);
1369
				_install_writeFile(fit, destdir.ToString(), errorStr);
Line 1662... Line 1648...
1662
		}
1648
		}
1663
	}
1649
	}
1664
 
1650
 
1665
	if (dir.Compare("NULL")) {
1651
	if (dir.Compare("NULL")) {
1666
		dir = Utils::String::Null();
1652
		dir = Utils::String::Null();
1667
	}
1653
	}
1668
 
1654
 
1669
	file->setFileType(type);
1655
	file->setFileType(type);
1670
	file->SetCreationTime ( time );
1656
	file->SetCreationTime ( time );
1671
	file->SetName ( name );
1657
	file->SetName ( name );
1672
	file->SetDir ( dir );
1658
	file->SetDir ( dir );
Line 1866... Line 1852...
1866
 
1852
 
1867
	// file mismatch
1853
	// file mismatch
1868
	long numfiles = m_lFiles.size();
1854
	long numfiles = m_lFiles.size();
1869
	if ( m_pIconFile ) ++numfiles;
1855
	if ( m_pIconFile ) ++numfiles;
1870
	if ( m_SHeader2.iNumFiles != numfiles ) {
1856
	if ( m_SHeader2.iNumFiles != numfiles ) {
1871
		m_iLastError = SPKERR_FILEMISMATCH;
1857
		_iLastError = SPKERR_FILEMISMATCH;
1872
		return false;
1858
		return false;
1873
	}
1859
	}
1874
 
1860
 
1875
	// update the progress for each section
1861
	// update the progress for each section
1876
	if ( readtype != SPKREAD_ALL && progress )	progress->UpdateProgress(6, maxProgress);
1862
	if ( readtype != SPKREAD_ALL && progress )	progress->UpdateProgress(6, maxProgress);
Line 2279... Line 2265...
2279
 
2265
 
2280
	// now were in the file section
2266
	// now were in the file section
2281
	// skip past each one
2267
	// skip past each one
2282
	if (m_pIconFile) File->seek(4 + m_pIconFile->GetDataSize());
2268
	if (m_pIconFile) File->seek(4 + m_pIconFile->GetDataSize());
2283
 
2269
 
2284
	for (CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next()) {
2270
	for (CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next()) 
-
 
2271
	{
2285
		C_File *fit = node->Data();
2272
		C_File *fit = node->Data();
2286
 
2273
 
2287
		if (progress)	progress->UpdateFile(fit);
2274
		if ((!fit->GetDataSize()) || (!fit->GetData())) 
2288
 
2275
		{
2289
		if ((!fit->GetDataSize()) || (!fit->GetData())) {
2276
			if (!fit->readFromFile(*File, fit->GetDataSize())) 
2290
			if (!fit->readFromFile(*File, fit->GetDataSize())) return false;
2277
				return false;
2291
		}
2278
		}
2292
		else
2279
		else
2293
			File->seek(fit->GetDataSize());
2280
			File->seek(fit->GetDataSize());
2294
 
2281
 
2295
		if (game && !fit->isForGame(game))
2282
		if (game && !fit->isForGame(game))
2296
			continue;
2283
			continue;
-
 
2284
 
-
 
2285
		if (progress)	
-
 
2286
			progress->UpdateFile(fit);
2297
 
2287
 
2298
		CDirIO Dir(dir);
2288
		CDirIO Dir(dir);
2299
		Utils::String addonDir;
2289
		Utils::String addonDir;
2300
		if (fit->isFileInAddon())
2290
		if (fit->isFileInAddon())
2301
		{
2291
		{
Line 2715... Line 2705...
2715
					if (first)
2705
					if (first)
2716
						first = false;
2706
						first = false;
2717
					else
2707
					else
2718
						s += "|";
2708
						s += "|";
2719
					s += CBaseFile::ConvertGameToString(i);
2709
					s += CBaseFile::ConvertGameToString(i);
2720
				}
2710
				}
2721
			}
2711
			}
2722
		}
2712
		}
2723
 
2713
 
2724
		s += " " + name;
2714
		s += " " + name;
2725
		if(!files.contains(s))
2715
		if(!files.contains(s))
2726
			files.pushBack(s, f->Data()->GetFileTypeString().ToString());
2716
			files.pushBack(s, f->Data()->GetFileTypeString().ToString());
2727
	}
2717
	}
Line 2841... Line 2831...
2841
	filename = filename.findReplace("$CDATE", cdate);
2831
	filename = filename.findReplace("$CDATE", cdate);
2842
	filename = filename.findReplace("$VERSION", this->version());
2832
	filename = filename.findReplace("$VERSION", this->version());
2843
 
2833
 
2844
	return filename;
2834
	return filename;
2845
}
2835
}
2846
bool CBaseFile::LoadPackageData(const Utils::String &sFirst, const Utils::String &sRest, const Utils::String &sMainGame, Utils::CStringList &otherGames, Utils::CStringList &gameAddons)
2836
bool CBaseFile::LoadPackageData(const Utils::String &sFirst, const Utils::String &sRest, const Utils::String &sMainGame, Utils::CStringList &otherGames, Utils::CStringList &gameAddons, CProgressInfo *progress)
2847
{
2837
{
2848
	if ( sFirst.Compare("Name") )					this->setName(sRest);
2838
	if (sFirst.Compare("Name"))					this->setName(sRest);
2849
	else if ( sFirst.Compare("Author") )			this->setAuthor(sRest);
2839
	else if (sFirst.Compare("Author"))			this->setAuthor(sRest);
2850
	else if ( sFirst.Compare("ScriptName") )
2840
	else if (sFirst.Compare("ScriptName"))
2851
		AddLanguageName(ParseLanguage(sRest.token(" ", 1)), sRest.tokens(" ", 2));
2841
		AddLanguageName(ParseLanguage(sRest.token(" ", 1)), sRest.tokens(" ", 2));
2852
	else if ( sFirst.Compare("UninstallBefore") )	this->addUninstallText(ParseLanguage(sRest.token(" ", 1)), true, sRest.tokens(" ", 2));
2842
	else if (sFirst.Compare("UninstallBefore"))	this->addUninstallText(ParseLanguage(sRest.token(" ", 1)), true, sRest.tokens(" ", 2));
2853
	else if ( sFirst.Compare("UninstallAfter") )	this->addUninstallText(ParseLanguage(sRest.token(" ", 1)), false, sRest.tokens(" ", 2));
2843
	else if (sFirst.Compare("UninstallAfter"))	this->addUninstallText(ParseLanguage(sRest.token(" ", 1)), false, sRest.tokens(" ", 2));
2854
	else if ( sFirst.Compare("InstallBefore") )		this->addInstallText(ParseLanguage(sRest.token(" ", 1)), true, sRest.tokens(" ", 2));
2844
	else if (sFirst.Compare("InstallBefore"))		this->addInstallText(ParseLanguage(sRest.token(" ", 1)), true, sRest.tokens(" ", 2));
2855
	else if ( sFirst.Compare("InstallAfter") )		this->addInstallText(ParseLanguage(sRest.token(" ", 1)), false, sRest.tokens(" ", 2));
2845
	else if (sFirst.Compare("InstallAfter"))		this->addInstallText(ParseLanguage(sRest.token(" ", 1)), false, sRest.tokens(" ", 2));
2856
	else if ( sFirst.Compare("Date") )				this->setCreationDate(sRest);
2846
	else if (sFirst.Compare("Date"))				this->setCreationDate(sRest);
2857
	else if ( sFirst.Compare("Version") )			this->setVersion(sRest);
2847
	else if (sFirst.Compare("Version"))			this->setVersion(sRest);
2858
	else if ( sFirst.Compare("GameVersion") )
2848
	else if (sFirst.Compare("GameVersion"))
2859
		this->AddGameCompatability(-1, sRest);
2849
		this->AddGameCompatability(-1, sRest);
2860
	else if ( sFirst.Compare("PluginType") ) {
2850
	else if (sFirst.Compare("PluginType")) {
2861
		if ( sRest.isNumber() )						this->setPluginType(sRest);
2851
		if (sRest.isNumber())						this->setPluginType(sRest);
2862
		else if ( sRest.Compare("Normal") )			this->setPluginType(PLUGIN_NORMAL);
2852
		else if (sRest.Compare("Normal"))			this->setPluginType(PLUGIN_NORMAL);
2863
		else if ( sRest.Compare("Stable") )			this->setPluginType(PLUGIN_STABLE);
2853
		else if (sRest.Compare("Stable"))			this->setPluginType(PLUGIN_STABLE);
2864
		else if ( sRest.Compare("Experimental") )	this->setPluginType(PLUGIN_EXPERIMENTAL);
2854
		else if (sRest.Compare("Experimental"))	this->setPluginType(PLUGIN_EXPERIMENTAL);
2865
		else if ( sRest.Compare("Cheat") )			this->setPluginType(PLUGIN_CHEAT);
2855
		else if (sRest.Compare("Cheat"))			this->setPluginType(PLUGIN_CHEAT);
2866
		else if ( sRest.Compare("Mod") )			this->setPluginType(PLUGIN_MOD);
2856
		else if (sRest.Compare("Mod"))			this->setPluginType(PLUGIN_MOD);
2867
	}
2857
	}
2868
	// new version
2858
	// new version
2869
	else if ( sFirst.Compare("GenerateUpdateFile") )
2859
	else if (sFirst.Compare("GenerateUpdateFile"))
2870
		m_bAutoGenerateUpdateFile = true;
2860
		m_bAutoGenerateUpdateFile = true;
2871
	else if ( sFirst.Compare("Game") )
2861
	else if (sFirst.Compare("Game"))
2872
	{
2862
	{
2873
		Utils::String sGame = sRest.token(" ", 1);
2863
		Utils::String sGame = sRest.token(" ", 1);
2874
		this->AddGameCompatability(CBaseFile::GetGameFromString(sGame), sRest.token(" ", 2));
2864
		this->AddGameCompatability(CBaseFile::GetGameFromString(sGame), sRest.token(" ", 2));
2875
	}
2865
	}
2876
	else if ( sFirst.Compare("Description") )		this->setDescription(sRest);
2866
	else if (sFirst.Compare("Description"))		this->setDescription(sRest);
2877
	else if ( sFirst.Compare(";AutoSave") || sFirst.Compare("AutoExport") || sFirst.Compare("AutoRarExport") || sFirst.Compare("AutoZipExport") )
2867
	else if (sFirst.Compare("AutoSave") || sFirst.Compare("AutoExport") || sFirst.Compare(";AutoRarExport") || sFirst.Compare("AutoZipExport"))
2878
	{
2868
	{
2879
		Utils::String filename = _replaceFilename(sRest);
2869
		Utils::String filename = _replaceFilename(sRest);
2880
 
2870
 
2881
		if ( sFirst.Compare("AutoZipExport") || sFirst.Compare(";AutoExport") )
2871
		if (sFirst.Compare("AutoZipExport") || sFirst.Compare(";AutoExport"))
2882
			this->setExportFilename(CFileIO(filename).changeFileExtension("zip"));
2872
			this->setExportFilename(CFileIO(filename).changeFileExtension("zip"));
2883
		else if ( sFirst.Compare("AutoRarExport") )
2873
		else if (sFirst.Compare("AutoRarExport"))
2884
			this->setExportFilename(CFileIO(filename).changeFileExtension("rar"));
2874
			this->setExportFilename(CFileIO(filename).changeFileExtension("rar"));
2885
		else
2875
		else
2886
			this->setFilename(filename);
2876
			this->setFilename(filename);
2887
	}
2877
	}
2888
	else if ( sFirst.Compare("WebSite") )		this->setWebSite(sRest);
2878
	else if (sFirst.Compare("WebSite"))		this->setWebSite(sRest);
2889
	else if ( sFirst.Compare("ForumLink") || sFirst.Compare(";Forum") ) this->setForumLink(sRest);
2879
	else if (sFirst.Compare("ForumLink") || sFirst.Compare(";Forum")) this->setForumLink(sRest);
2890
	else if ( sFirst.Compare("Email") )			this->setEmail(sRest);
2880
	else if (sFirst.Compare("Email"))			this->setEmail(sRest);
2891
	else if ( sFirst.Compare("WebAddress") )	this->setWebAddress(sRest);
2881
	else if (sFirst.Compare("WebAddress"))	this->setWebAddress(sRest);
2892
	else if ( sFirst.Compare("WebMirror") )
2882
	else if (sFirst.Compare("WebMirror"))
2893
		this->AddWebMirror(sRest);
2883
		this->AddWebMirror(sRest);
2894
	else if ( sFirst.Compare("WebMirror1") )
2884
	else if (sFirst.Compare("WebMirror1"))
2895
		this->AddWebMirror(sRest);
2885
		this->AddWebMirror(sRest);
2896
	else if ( sFirst.Compare("WebMirror2") )
2886
	else if (sFirst.Compare("WebMirror2"))
2897
		this->AddWebMirror(sRest);
2887
		this->AddWebMirror(sRest);
2898
	else if ( sFirst.Compare("Ftp") )
2888
	else if (sFirst.Compare("Ftp"))
2899
		m_sFtpAddr = sRest;
2889
		m_sFtpAddr = sRest;
2900
	else if ( sFirst.Compare("Ratings") )		_setRatings(sRest.token(" ", 1), sRest.token(" ", 2), sRest.token(" ", 3));
2890
	else if (sFirst.Compare("Ratings"))		_setRatings(sRest.token(" ", 1), sRest.token(" ", 2), sRest.token(" ", 3));
2901
	else if ( sFirst.Compare("EaseOfUse") )		setEaseOfUse(sRest);
2891
	else if (sFirst.Compare("EaseOfUse"))		setEaseOfUse(sRest);
2902
	else if ( sFirst.Compare("GameChanging"))	setGameChanging(sRest);
2892
	else if (sFirst.Compare("GameChanging"))	setGameChanging(sRest);
2903
	else if ( sFirst.Compare("Recommended") )	setRecommended(sRest);
2893
	else if (sFirst.Compare("Recommended"))	setRecommended(sRest);
2904
	else if ( sFirst.Compare("Depend") )
2894
	else if (sFirst.Compare("Depend"))
2905
	{
2895
	{
2906
		Utils::String version = sRest.token("|", 2);
2896
		Utils::String version = sRest.token("|", 2);
2907
		Utils::String name = sRest.token("|", 1);
2897
		Utils::String name = sRest.token("|", 1);
2908
		Utils::String author = sRest.tokens("|", 3);
2898
		Utils::String author = sRest.tokens("|", 3);
2909
 
2899
 
2910
		this->AddNeededLibrary(name, author, version);
2900
		this->AddNeededLibrary(name, author, version);
2911
	}
2901
	}
2912
	else if ( sFirst.Compare("DependPackage") )
2902
	else if (sFirst.Compare("DependPackage"))
2913
	{
2903
	{
2914
		CPackages p;
2904
		CPackages p;
2915
		CBaseFile *spk =  p.OpenPackage(sRest, 0, 0, SPKREAD_VALUES);
2905
		CBaseFile *spk = p.OpenPackage(sRest, 0, 0, SPKREAD_VALUES);
2916
		if ( spk )
2906
		if (spk)
2917
		{
2907
		{
2918
			this->AddNeededLibrary(spk->name(), spk->author(), spk->version());
2908
			this->AddNeededLibrary(spk->name(), spk->author(), spk->version());
2919
			delete spk;
2909
			delete spk;
2920
		}
2910
		}
2921
	}
2911
	}
2922
	else if (sFirst.Compare("Icon"))
2912
	else if (sFirst.Compare("Icon"))
2923
	{
2913
	{
2924
		C_File *icon = new C_File(sRest.c_str());
2914
		C_File *icon = new C_File(sRest.c_str());
2925
		if ( icon->ReadFromFile() )
2915
		if (icon->ReadFromFile())
2926
			this->SetIcon(icon, CFileIO(sRest).GetFileExtension());
2916
			this->SetIcon(icon, CFileIO(sRest).GetFileExtension());
2927
	}
2917
	}
2928
	else if (sFirst.Compare("CombineGameFiles"))
2918
	else if (sFirst.Compare("CombineGameFiles"))
2929
		_bCombineFiles = sRest.Compare("true") || sRest.Compare("yes") || sRest.toInt();
2919
		_bCombineFiles = sRest.Compare("true") || sRest.Compare("yes") || sRest.toInt();
-
 
2920
	else if (sFirst.Compare("UpdateFile"))
-
 
2921
		this->createUpdateFile(sRest);
2930
	else if (sFirst.Compare("ExportZip"))
2922
	else if (sFirst.Compare("ExportZip"))
2931
	{
2923
	{
2932
		Utils::String ext = "zip";
2924
		Utils::String ext = "zip";
2933
		Utils::String game = sRest.word(1);
2925
		Utils::String game = sRest.word(1);
2934
		Utils::String file = _replaceFilename(CFileIO(sRest.words(2)).fullFilename());
2926
		Utils::String file = _replaceFilename(CFileIO(sRest.words(2)).fullFilename());
2935
		if (game.contains("|"))
2927
		if (game.contains("|"))
2936
		{
2928
		{
2937
			int max;
2929
			int max;
2938
			Utils::String *games = game.tokenise("|", &max);
2930
			Utils::String *games = game.tokenise("|", &max);
2939
			if (games)
2931
			if (games)
2940
			{
2932
			{
2941
				for (int i = 0; i < max; ++i)
2933
				for (int i = 0; i < max; ++i)
2942
				{
2934
				{
2943
					unsigned int g = CBaseFile::GetGameFromString(games[i]);
2935
					unsigned int g = CBaseFile::GetGameFromString(games[i]);
Line 2983... Line 2975...
2983
		}
2975
		}
2984
 
2976
 
2985
		// now check type name
2977
		// now check type name
2986
		FileType filetype = GetFileTypeFromString(checkType);
2978
		FileType filetype = GetFileTypeFromString(checkType);
2987
		if (filetype != FILETYPE_UNKNOWN)
2979
		if (filetype != FILETYPE_UNKNOWN)
2988
			this->AddFileScript(filetype, shared, sRest, sMainGame, otherGames, gameAddons);
2980
			this->AddFileScript(filetype, shared, sRest, sMainGame, otherGames, gameAddons, progress);
2989
		else if ( !checkType.Compare("changelog") )
2981
		else if ( !checkType.Compare("changelog") )
2990
			return false;
2982
			return false;
2991
	}
2983
	}
2992
 
2984
 
2993
	return true;
2985
	return true;
2994
}
2986
}
2995
 
2987
 
2996
void CBaseFile::AddFileScript(FileType filetype, bool shared, CyString sRest, const Utils::String &sMainGame, Utils::CStringList &otherGames, Utils::CStringList &gameAddons)
2988
void CBaseFile::AddFileScript(FileType filetype, bool shared, CyString sRest, const Utils::String &sMainGame, Utils::CStringList &otherGames, Utils::CStringList &gameAddons, CProgressInfo *progress)
2997
{
2989
{
2998
	Utils::String dir;
2990
	Utils::String dir;
2999
	Utils::String rest = sRest.ToString();
2991
	Utils::String rest = sRest.ToString();
3000
 
2992
 
3001
	unsigned int mainGame = CBaseFile::GetGameFromString(sMainGame);
2993
	unsigned int mainGame = CBaseFile::GetGameFromString(sMainGame);
Line 3052... Line 3044...
3052
						for(Utils::String g = otherGames.firstString(); !g.empty(); g = otherGames.nextString()) {
3044
						for(Utils::String g = otherGames.firstString(); !g.empty(); g = otherGames.nextString()) {
3053
							Utils::String checkDir = F.dir() + "/" + g;
3045
							Utils::String checkDir = F.dir() + "/" + g;
3054
							if ( CDirIO(checkDir).exists(F.filename()) ) {
3046
							if ( CDirIO(checkDir).exists(F.filename()) ) {
3055
								addGame = mainGame;
3047
								addGame = mainGame;
3056
								C_File *newfile = this->AppendFile(CDirIO(checkDir).File(F.filename()), filetype, CBaseFile::GetGameFromString(g), dir);
3048
								C_File *newfile = this->AppendFile(CDirIO(checkDir).File(F.filename()), filetype, CBaseFile::GetGameFromString(g), dir);
-
 
3049
								if (newfile && progress)
-
 
3050
									progress->UpdateFile(newfile);
3057
								if ( newfile ) newfile->SetShared(shared);
3051
								if ( newfile ) newfile->SetShared(shared);
3058
							}
3052
							}
3059
						}
3053
						}
3060
					}
3054
					}
3061
 
3055
 
3062
					C_File *newfile = this->AppendFile(file, filetype, addGame, dir);
3056
					C_File *newfile = this->AppendFile(file, filetype, addGame, dir);
-
 
3057
					if (newfile && progress)
-
 
3058
						progress->UpdateFile(newfile);
3063
					if ( newfile )
3059
					if ( newfile )
3064
						newfile->SetShared(shared);
3060
						newfile->SetShared(shared);
3065
				}
3061
				}
3066
			}
3062
			}
3067
			delete dirList;
3063
			delete dirList;
Line 3076... Line 3072...
3076
			for(Utils::String g = otherGames.firstString(); !g.empty(); g = otherGames.nextString()) {
3072
			for(Utils::String g = otherGames.firstString(); !g.empty(); g = otherGames.nextString()) {
3077
				Utils::String checkDir = F.dir() + "/" + g;
3073
				Utils::String checkDir = F.dir() + "/" + g;
3078
				if ( CDirIO(checkDir).exists(F.filename()) ) {
3074
				if ( CDirIO(checkDir).exists(F.filename()) ) {
3079
					addGame = mainGame;
3075
					addGame = mainGame;
3080
					C_File *newfile = this->AppendFile(CDirIO(checkDir).file(F.filename()), filetype, CBaseFile::GetGameFromString(g), dir);
3076
					C_File *newfile = this->AppendFile(CDirIO(checkDir).file(F.filename()), filetype, CBaseFile::GetGameFromString(g), dir);
-
 
3077
					if (newfile && progress)
-
 
3078
						progress->UpdateFile(newfile);
3081
					if ( newfile ) newfile->SetShared(shared);
3079
					if ( newfile ) newfile->SetShared(shared);
3082
				}
3080
				}
3083
			}
3081
			}
3084
		}
3082
		}
3085
 
3083
 
Line 3111... Line 3109...
3111
		}
3109
		}
3112
 
3110
 
3113
		if(!file)
3111
		if(!file)
3114
			file = this->AppendFile(rest, filetype, addGame, dir);
3112
			file = this->AppendFile(rest, filetype, addGame, dir);
3115
 
3113
 
-
 
3114
		if (file && progress)
-
 
3115
			progress->UpdateFile(file);
3116
		if (file)
3116
		if (file)
3117
			file->SetShared(shared);
3117
			file->SetShared(shared);
3118
	}
3118
	}
3119
}
3119
}
3120
 
3120
 
Line 3236... Line 3236...
3236
		if ( match )
3236
		if ( match )
3237
			match->ChangeBaseName(baseName);
3237
			match->ChangeBaseName(baseName);
3238
	}
3238
	}
3239
 
3239
 
3240
	// need to edit the file
3240
	// need to edit the file
3241
if (f->GetFileType() == FILETYPE_SCRIPT || f->GetFileType() == FILETYPE_UNINSTALL)
3241
	if (f->GetFileType() == FILETYPE_SCRIPT || f->GetFileType() == FILETYPE_UNINSTALL)
3242
f->RenameScript(baseName);
3242
		f->RenameScript(baseName);
3243
 
3243
 
3244
f->ChangeBaseName(baseName);
3244
	f->ChangeBaseName(baseName);
3245
}
3245
}
3246
 
3246
 
3247
CyString CBaseFile::CreateUpdateFile(CyString dir)
3247
Utils::String CBaseFile::createUpdateFile(const Utils::String &dir) const
3248
{
3248
{
3249
	CyString file = this->GetNameValidFile() + "_" + this->author() + ".dat";
3249
	Utils::String file = this->getNameValidFile() + "_" + this->author() + ".dat";
3250
	file.RemoveChar(' ');
3250
	file.removeChar(' ');
3251
 
3251
 
3252
	CyStringList write;
3252
	Utils::CStringList write;
3253
	write.PushBack(CyString("Package: ") + this->name());
3253
	write.pushBack("Package: " + this->name());
3254
	write.PushBack(CyString("Author: ") + this->author());
3254
	write.pushBack("Author: " + this->author());
3255
	write.PushBack(CyString("Version: ") + this->version());
3255
	write.pushBack("Version: " + this->version());
3256
	write.PushBack(CyString("File: ") + CFileIO(this->filename()).filename());
3256
	write.pushBack("File: " + CFileIO(this->filename()).filename());
3257
 
3257
 
3258
	CFileIO File(dir + "/" + file);
3258
	CFileIO File(dir + "/" + file);
3259
	if (File.WriteFile(&write))
3259
	if (File.writeFile(&write))
3260
		return File.fullFilename();
3260
		return File.fullFilename();
3261
	return NullString;
3261
	return Utils::String::Null();
3262
}
3262
}
3263
 
3263
 
3264
CyString CBaseFile::ErrorString(int error, CyString errorStr)
3264
Utils::String CBaseFile::ErrorString(int error, const Utils::String &errorStr)
3265
{
3265
{
3266
	if (error == SPKERR_NONE) return NullString;
3266
	if (error == SPKERR_NONE) return Utils::String::Null();
3267
 
3267
 
3268
	CyString err;
3268
	Utils::String err;
3269
 
3269
 
3270
	switch (error)
3270
	switch (error)
3271
	{
3271
	{
3272
	case SPKERR_MALLOC:
3272
	case SPKERR_MALLOC:
3273
		err = "Memory Failed";
3273
		err = "Memory Failed";
Line 3290... Line 3290...
3290
	case SPKERR_FILEMISMATCH:
3290
	case SPKERR_FILEMISMATCH:
3291
		err = "File count mismatch";
3291
		err = "File count mismatch";
3292
		break;
3292
		break;
3293
	}
3293
	}
3294
 
3294
 
3295
	if (!err.Empty())
3295
	if (!err.empty())
3296
	{
3296
	{
3297
		if (!errorStr.Empty())
3297
		if (!errorStr.empty())
3298
		{
3298
		{
3299
			err += " (";
3299
			err += " (";
3300
			err += errorStr + ")";
3300
			err += errorStr + ")";
3301
		}
3301
		}
3302
		return err;
3302
		return err;
3303
	}
3303
	}
3304
 
3304
 
3305
	return CyString((long)error);
3305
	return Utils::String::Number((long)error);
3306
}
3306
}
3307
 
3307
 
3308
bool CBaseFile::SaveToArchive(CyString filename, int game, const CGameExe *exes, CProgressInfo *progress)
3308
bool CBaseFile::SaveToArchive(CyString filename, int game, const CGameExe *exes, CProgressInfo *progress)
3309
{
3309
{
3310
	return saveToArchive(filename.ToString(), game, exes, progress);
3310
	return saveToArchive(filename.ToString(), game, exes, progress);