Subversion Repositories spk

Rev

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

Rev 78 Rev 79
Line 1... Line 1...
1
 
1
 
2
#include "VirtualFileSystem.h"
2
#include "VirtualFileSystem.h"
3
#include "File_IO.h"
3
#include "File_IO.h"
4
#include "CatFile.h"
4
#include "CatFile.h"
5
#include "XspFile.h"
5
#include "XspFile.h"
-
 
6
 
-
 
7
#include "Packages.h"
6
 
8
 
7
namespace SPK {
9
namespace SPK {
8
 
10
 
9
CVirtualFileSystem::CVirtualFileSystem()
11
CVirtualFileSystem::CVirtualFileSystem()
10
{
12
{
Line 323... Line 325...
323
	return this->extractGameFileToPackage(pPackage, sFile, iFileType, sFile);
325
	return this->extractGameFileToPackage(pPackage, sFile, iFileType, sFile);
324
}
326
}
325
 
327
 
326
C_File *CVirtualFileSystem::extractGameFileToPackage(CBaseFile *pPackage, const Utils::String &sFile, FileType iFileType, const Utils::String &sTo)
328
C_File *CVirtualFileSystem::extractGameFileToPackage(CBaseFile *pPackage, const Utils::String &sFile, FileType iFileType, const Utils::String &sTo)
327
{
329
{
328
	Utils::String to = this->ExtractGameFile(sFile, "tmp");
330
	Utils::String to = this->ExtractGameFile(sFile, CPackages::tempDirectory() + "tmp.dat");
329
	if ( !to.empty() ) {
331
	if ( !to.empty() ) {
330
		CFileIO File(to);
332
		CFileIO File(to);
331
 
333
 
332
		C_File *f = pPackage->AddFile(CFileIO(sTo).GetFilename(), CFileIO(sTo).GetDir(), iFileType);
334
		C_File *f = pPackage->AddFile(CFileIO(sTo).GetFilename(), CFileIO(sTo).GetDir(), iFileType);
333
		if ( f ) {
335
		if ( f ) {
334
			if ( f->ReadFromFile("tmp") ) {
336
			if ( f->ReadFromFile(CPackages::GetTempDirectory() + "tmp.dat") ) {
335
				File.remove();
337
				File.remove();
336
				return f;
338
				return f;
337
			}
339
			}
338
		}
340
		}
339
 
341
 
Line 368... Line 370...
368
		else {
370
		else {
369
			if ( !str.left(2).Compare("t\\") && !str.left(2).Compare("t/") && !str.left(8).Compare("addon\t\\") && !str.left(8).Compare("addon/t/") )
371
			if ( !str.left(2).Compare("t\\") && !str.left(2).Compare("t/") && !str.left(8).Compare("addon\t\\") && !str.left(8).Compare("addon/t/") )
370
				continue;
372
				continue;
371
		}
373
		}
372
 
374
 
373
		Utils::String sTo = this->ExtractGameFile(str, "tmp");
375
		Utils::String sTo = this->ExtractGameFile(str, CPackages::tempDirectory() + "tmp.dat");
374
		if ( !sTo.empty() ) {
376
		if ( !sTo.empty() ) {
375
			pPackage->AddTextFromFile(sTo, textId);
377
			pPackage->AddTextFromFile(sTo, textId);
376
			CFileIO::Remove(sTo);
378
			CFileIO::Remove(sTo);
377
		}
379
		}
378
	}
380
	}
Line 418... Line 420...
418
		else {
420
		else {
419
			if ( !str.left(2).Compare("t\\") && !str.left(2).Compare("t/") )
421
			if ( !str.left(2).Compare("t\\") && !str.left(2).Compare("t/") )
420
				continue;
422
				continue;
421
		}
423
		}
422
 
424
 
423
		Utils::String sTo = this->ExtractGameFile(str, "tmp");
425
		Utils::String sTo = this->ExtractGameFile(str, CPackages::tempDirectory() + "tmp.dat");
424
		if ( !sTo.empty() ) {
426
		if ( !sTo.empty() ) {
425
			// add all texts into the map, id=(pageid, tid) data=text
427
			// add all texts into the map, id=(pageid, tid) data=text
426
			Utils::String baseFile = CFileIO(str).baseName();
428
			Utils::String baseFile = CFileIO(str).baseName();
427
			int lang = (baseFile.isin("-L")) ? baseFile.right(3) : baseFile.truncate(-4);
429
			int lang = (baseFile.isin("-L")) ? baseFile.right(3) : baseFile.truncate(-4);
428
 
430
 
Line 446... Line 448...
446
 
448
 
447
bool CVirtualFileSystem::loadShipData(CyStringList *list)
449
bool CVirtualFileSystem::loadShipData(CyStringList *list)
448
{
450
{
449
	bool ret = false;
451
	bool ret = false;
450
 
452
 
451
	Utils::String sTo = this->ExtractGameFile("types/TShips.pck", "tmp");
453
	Utils::String sTo = this->ExtractGameFile("types/TShips.pck", CPackages::tempDirectory() + "tmp.dat");
452
	if ( !sTo.empty() ) {
454
	if ( !sTo.empty() ) {
453
		CFileIO File(sTo);
455
		CFileIO File(sTo);
454
		CyStringList *lines = File.ReadLinesStr();
456
		CyStringList *lines = File.ReadLinesStr();
455
		if ( lines )
457
		if ( lines )
456
		{
458
		{