Subversion Repositories spk

Rev

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

Rev 13 Rev 14
Line 6... Line 6...
6
 
6
 
7
// old style compression (needed to convert old formats)
7
// old style compression (needed to convert old formats)
8
#include "../../HiP/HiP.h"
8
#include "../../HiP/HiP.h"
9
 
9
 
10
//TODO: remove this
10
//TODO: remove this
11
unsigned char *LineByLineRead ( unsigned char *data, CyString end, CyString *readData )
11
unsigned char *LineByLineRead ( unsigned char *data, const Utils::String &end, Utils::String *readData )
12
{
12
{
13
	CyString line;
13
	Utils::String line;
14
	while ( true )
14
	while ( true )
15
	{
15
	{
16
		data = line.GetEndOfLine(data);
16
		data = line.readToEndOfLine(data);
17
		//data = ReadNextLine ( data, len, &line );
-
 
18
 
17
 
19
		if ( (*readData).Empty() && line.Empty() ) continue;
18
		if ( (*readData).empty() && line.empty() ) continue;
20
		if ( line == end )
19
		if ( line == end )
21
			break;
20
			break;
22
		*readData += (line + "\r\n");
21
		*readData += (line + "\r\n");
23
	}
22
	}
24
 
23
 
Line 58... Line 57...
58
 
57
 
59
	CBaseFile::Delete ();
58
	CBaseFile::Delete ();
60
}
59
}
61
 
60
 
62
 
61
 
63
bool CSpkFile::CheckHeader ( CyString header )
62
bool CSpkFile::CheckHeader(const Utils::String header) const
64
{
63
{
65
	if ( header.Compare("SPKCycrow") )
64
	if ( header.Compare("SPKCycrow") )
66
		return true;
65
		return true;
67
	return false;
66
	return false;
68
}
67
}
Line 70... Line 69...
70
	Func:   ParseValueLine
69
	Func:   ParseValueLine
71
	Input:  String - single line from a file to set
70
	Input:  String - single line from a file to set
72
	Return: Boolean - returns true if value exists
71
	Return: Boolean - returns true if value exists
73
	Desc:   Reads the line and assigns the parameters for the file
72
	Desc:   Reads the line and assigns the parameters for the file
74
*/
73
*/
75
bool CSpkFile::ParseValueLine ( CyString line )
74
bool CSpkFile::ParseValueLine(const Utils::String &line)
76
{
75
{
77
	Utils::String first = line.GetToken ( 1, ' ' ).ToString();
76
	Utils::String first = line.token(" ", 1);
78
	Utils::String rest  = line.GetToken ( 2, -1, ' ' ).ToString();
77
	Utils::String rest  = line.tokens(" ", 2);
79
 
78
 
80
	if ( first == "AnotherMod:" )
79
	if ( first == "AnotherMod:" )
81
	{
80
	{
82
		m_sOtherAuthor = rest.token("|", 1);
81
		m_sOtherAuthor = rest.token("|", 1);
83
		m_sOtherName = rest.tokens("|", 2);
82
		m_sOtherName = rest.tokens("|", 2);
Line 116... Line 115...
116
/*
115
/*
117
	Func:   CreateValuesLine
116
	Func:   CreateValuesLine
118
	Return: String - returns the full string for values
117
	Return: String - returns the full string for values
119
	Desc:   Creates a single string for all values, this is used when compressing to write to the spk file
118
	Desc:   Creates a single string for all values, this is used when compressing to write to the spk file
120
*/
119
*/
121
CyString CSpkFile::CreateValuesLine ()
120
Utils::String CSpkFile::CreateValuesLine () const
122
{
121
{
123
	CyString values = CBaseFile::CreateValuesLine ();
122
	Utils::String values = CBaseFile::CreateValuesLine ();
124
	// combine all values together
123
	// combine all values together
125
	if ( (!m_sOtherAuthor.empty()) && (!m_sOtherName.empty()) )
124
	if ( (!m_sOtherAuthor.empty()) && (!m_sOtherName.empty()) )
126
		values += (CyString("AnotherMod: ") + m_sOtherAuthor + "|" + m_sOtherName + "\n");
125
		values += "AnotherMod: " + m_sOtherAuthor + "|" + m_sOtherName + "\n";
127
	if ( m_bForceProfile )
126
	if ( m_bForceProfile )
128
		values += "ForceProfile\n";
127
		values += "ForceProfile\n";
129
	if ( !m_sScriptType.empty() )
128
	if ( !m_sScriptType.empty() )
130
		values += (CyString("ScriptType: ") + m_sScriptType + "\n");
129
		values += "ScriptType: " + m_sScriptType + "\n";
131
	values += (CyString(";PackageType: ") + (long)m_iPackageType + "\n");
130
	values += Utils::String(";PackageType: ") + (long)m_iPackageType + "\n";
132
	values += (CyString(";ScriptTypeNew: ") + (long)m_iScriptType + "\n");
131
	values += Utils::String(";ScriptTypeNew: ") + (long)m_iScriptType + "\n";
133
 
132
 
134
	for ( SSettingType *st = m_lSettings.First(); st; st = m_lSettings.Next() )
133
	for ( CListNode<SSettingType> *node = m_lSettings.Front(); node; node = node->next() )
135
		values += (CyString(&quot;Setting: ") + CyString::Number(st->iType) + "|" + st->sKey + "|" + GetSetting(st) + "\n");
134
		values += Utils::String(&quot;Setting: ") + (long)node->Data()->iType + "|" + node->Data()->sKey + "|" + GetSetting(node->Data()) + "\n";
136
 
135
 
137
	for ( SWares *ware = m_lWares.First(); ware; ware = m_lWares.Next() )
136
	for ( CListNode<SWares> *wNode = m_lWares.Front(); wNode; wNode = wNode->next() ) {
138
	{
-
 
-
 
137
		SWares *ware = wNode->Data();
139
		if ( ware->iTextID > 0 )
138
		if ( wNode->Data()->iTextID > 0 )
140
			values += CyString("Ware: ") + ware->cType + ":" + ware->iPrice + ":" + (long)ware->iSize + ":" + (long)ware->iVolumn + ":" + ware->sID + ":" + (long)ware->iNotority + ":" + (long)ware->iTextID + "," + (long)ware->iTextPage + "\n";
139
			values += Utils::String("Ware: ") + ware->cType + ":" + ware->iPrice + ":" + (long)ware->iSize + ":" + (long)ware->iVolumn + ":" + ware->sID + ":" + (long)ware->iNotority + ":" + (long)ware->iTextID + "," + (long)ware->iTextPage + "\n";
141
		else
140
		else
142
			values += CyString("Ware: ") + ware->cType + ":" + ware->iPrice + ":" + (long)ware->iSize + ":" + (long)ware->iVolumn + ":" + ware->sID + ":" + (long)ware->iNotority + "\n";
141
			values += Utils::String("Ware: ") + ware->cType + ":" + ware->iPrice + ":" + (long)ware->iSize + ":" + (long)ware->iVolumn + ":" + ware->sID + ":" + (long)ware->iNotority + "\n";
143
		for ( SWaresText *wt = ware->lText.First(); wt; wt = ware->lText.Next() )
142
		for ( CListNode<SWaresText> *wtNode = ware->lText.Front(); wtNode; wtNode = wtNode->next() )
144
			values += CyString("WareText: ") + (long)wt->iLang + &quot; &quot; + wt->sName + "|" + wt->sDesc + "\n";
143
			values += Utils::String("WareText: ") + (long)wtNode->Data()->iLang + " " + wtNode->Data()->sName + &quot;|&quot; + wtNode->Data()->sDesc + "\n";
145
	}
144
	}
146
 
145
 
147
	return values;
146
	return values;
148
}
147
}
149
 
148
 
Line 257... Line 256...
257
	// skip the icon file
256
	// skip the icon file
258
	if ( m_pIconFile )
257
	if ( m_pIconFile )
259
	{
258
	{
260
		fseek ( id, 4, SEEK_CUR );
259
		fseek ( id, 4, SEEK_CUR );
261
		fseek ( id, m_pIconFile->GetDataSize (), SEEK_CUR );
260
		fseek ( id, m_pIconFile->GetDataSize (), SEEK_CUR );
262
	}
261
	}
263
 
262
 
264
	// now were in the file section
263
	// now were in the file section
265
	// skip past each one
264
	// skip past each one
266
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
265
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
267
	{
266
	{
268
		C_File *fit = node->Data();
267
		C_File *fit = node->Data();
Line 378... Line 377...
378
}
377
}
379
 
378
 
380
void CSpkFile::ClearWareText(SWares *w)
379
void CSpkFile::ClearWareText(SWares *w)
381
{
380
{
382
	if ( !w ) return;
381
	if ( !w ) return;
383
 
382
 
384
	w->lText.clear(true);
383
	w->lText.clear(true);
385
	m_bChanged = true;
384
	m_bChanged = true;
386
}
385
}
387
 
386
 
388
void CSpkFile::RemoveWareText(const Utils::String &wid, int lang)
387
void CSpkFile::RemoveWareText(const Utils::String &wid, int lang)
Line 407... Line 406...
407
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
406
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
408
	{
407
	{
409
		C_File *file = node->Data();
408
		C_File *file = node->Data();
410
		if ( file->GetFileType() != FILETYPE_SCRIPT )
409
		if ( file->GetFileType() != FILETYPE_SCRIPT )
411
			continue;
410
			continue;
412
 
411
 
413
		CyString basename = file->GetName().GetToken ( 1, file->GetName().NumToken('.') - 1, '.' );
412
		Utils::String basename = file->GetName().GetToken ( 1, file->GetName().NumToken('.') - 1, '.' ).ToString();
414
		if ( basename.ToLower().Right(15) == ";.initplayership" )
413
		if ( basename.right(15).Compare(";.initplayership") )
415
			return 0;
414
			return 0;
416
	}
415
	}
417
	if ( !IsAnotherMod() )
416
	if ( !IsAnotherMod() )
418
		return 1;
417
		return 1;
419
	else
418
	else
420
		return 2;
419
		return 2;
421
}
420
}
422
 
421
 
423
bool CSpkFile::UpdateSigned (bool updateFiles)
422
bool CSpkFile::UpdateSigned (bool updateFiles)
424
{
423
{
425
	// check for any custom wares
424
	// check for any custom wares
426
	// patch mods and custom starts are also not signed
425
	// patch mods and custom starts are also not signed
Line 431... Line 430...
431
	}
430
	}
432
 
431
 
433
	return CBaseFile::UpdateSigned(updateFiles);
432
	return CBaseFile::UpdateSigned(updateFiles);
434
}
433
}
435
 
434
 
436
CSpkFile::SSettingType *CSpkFile::AddSetting(const Utils::String &key, int type )
435
SSettingType *CSpkFile::AddSetting(const Utils::String &key, int type )
437
{
436
{
438
	Utils::String sKey = key.removeChar('|');
437
	Utils::String sKey = key.removeChar('|');
439
 
438
 
440
	SSettingType *t;
439
	SSettingType *t;
441
	for ( t = m_lSettings.First(); t; t = m_lSettings.Next() )
440
	for ( t = m_lSettings.First(); t; t = m_lSettings.Next() )
442
	{
441
	{
443
		if ( t->sKey.Compare(sKey) )
442
		if ( t->sKey.Compare(sKey) )
444
			return NULL;
443
			return NULL;
445
	}
444
	}
446
 
445
 
447
	switch ( type )
446
	switch ( type )
448
	{
447
	{
449
		case SETTING_STRING:
448
		case SETTING_STRING:
450
			t = new SSettingString;
449
			t = new SSettingString;
451
			break;
450
			break;
452
		case SETTING_INTEGER:
451
		case SETTING_INTEGER:
453
			t = new SSettingInteger;
452
			t = new SSettingInteger;
454
			break;
453
			break;
455
		case SETTING_CHECK:
454
		case SETTING_CHECK:
456
			t = new SSettingCheck;
455
			t = new SSettingCheck;
457
			break;
456
			break;
458
	}
457
	}
459
 
458
 
460
	if ( !t )
459
	if ( !t )
461
		return NULL;
460
		return NULL;
462
 
461
 
463
	t->sKey = sKey;
462
	t->sKey = sKey;
464
	t->iType = type;
463
	t->iType = type;
465
 
464
 
466
	m_lSettings.push_back ( t );
465
	m_lSettings.push_back ( t );
Line 471... Line 470...
471
 
470
 
472
void CSpkFile::ConvertSetting ( SSettingType *t, const Utils::String &set ) const
471
void CSpkFile::ConvertSetting ( SSettingType *t, const Utils::String &set ) const
473
{
472
{
474
	if ( !t )
473
	if ( !t )
475
		return;
474
		return;
476
 
475
 
477
	switch ( t->iType )
476
	switch ( t->iType )
478
	{
477
	{
479
		case SETTING_STRING:
478
		case SETTING_STRING:
480
			((SSettingString *)t)->sValue = set;
479
			((SSettingString *)t)->sValue = set;
481
			break;
480
			break;
482
		case SETTING_INTEGER:
481
		case SETTING_INTEGER:
483
			((SSettingInteger *)t)->iValue = set;
482
			((SSettingInteger *)t)->iValue = set;
484
			break;
483
			break;
485
		case SETTING_CHECK:
484
		case SETTING_CHECK:
486
			((SSettingCheck *)t)->bValue = set;
485
			((SSettingCheck *)t)->bValue = set;
487
			break;
486
			break;
488
	}
487
	}
489
}
488
}
Line 501... Line 500...
501
		case SETTING_CHECK:
500
		case SETTING_CHECK:
502
			return (((SSettingInteger *)t)->iValue) ? "1" : "0";
501
			return (((SSettingInteger *)t)->iValue) ? "1" : "0";
503
	}
502
	}
504
 
503
 
505
	return "";
504
	return "";
506
}
505
}
507
 
506
 
508
void CSpkFile::ClearSettings ()
507
void CSpkFile::ClearSettings ()
509
{
508
{
510
	m_lSettings.clear(true);
509
	m_lSettings.clear(true);
511
	m_bChanged = true;
510
	m_bChanged = true;
512
}
511
}
513
 
512
 
514
 
513
 
515
bool CSpkFile::IsMatchingMod(const Utils::String &mod) const
514
bool CSpkFile::IsMatchingMod(const Utils::String &mod) const
516
{
515
{
517
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
516
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
518
	{
517
	{
Line 560... Line 559...
560
 
559
 
561
	if ( sType.empty() )
560
	if ( sType.empty() )
562
		return "Other";
561
		return "Other";
563
 
562
 
564
	return sType;	
563
	return sType;	
565
}
564
}
566
 
565
 
567
int CSpkFile::ConvertScriptType(const Utils::String &sType)
566
int CSpkFile::ConvertScriptType(const Utils::String &sType)
568
{
567
{
569
	for ( int i = 0; i < SCRIPTTYPE_MAX; i++ )
568
	for ( int i = 0; i < SCRIPTTYPE_MAX; i++ )
570
	{
569
	{
571
		if ( sType.Compare(CSpkFile::GetScriptTypeStringStatic(i)) )
570
		if ( sType.Compare(CSpkFile::GetScriptTypeStringStatic(i)) )
572
			return i;
571
			return i;
573
	}
572
	}
574
 
573
 
575
	return -1;
574
	return -1;
576
}
575
}
577
 
576
 
578
Utils::String CSpkFile::GetScriptTypeStringStatic(int type)
577
Utils::String CSpkFile::GetScriptTypeStringStatic(int type)
579
{
578
{
Line 620... Line 619...
620
	}
619
	}
621
 
620
 
622
	return "Other";
621
	return "Other";
623
}
622
}
624
 
623
 
625
bool CSpkFile::LoadPackageData(CyString first, CyString sRest)
624
bool CSpkFile::LoadPackageData(const Utils::String &sFirst, const Utils::String &sRest)
626
{
625
{
627
	Utils::String rest = sRest.ToString();
-
 
628
 
-
 
629
	if ( first.Compare("ScriptType") )
626
	if ( sFirst.Compare("ScriptType") )
630
	{
627
	{
631
		if ( rest.Compare("Library") || rest.Compare("Library Script") )
628
		if ( sRest.Compare("Library") || sRest.Compare("Library Script") )
632
			this->SetLibrary();
629
			this->SetLibrary();
633
		else if ( rest.Compare("Update") || rest.Compare("Package Update") || rest.Compare("Mod Update") )
630
		else if ( sRest.Compare("Update") || sRest.Compare("Package Update") || sRest.Compare("Mod Update") )
634
			this->SetPackageUpdate();
631
			this->SetPackageUpdate();
635
		else if ( rest.Compare("Start") || rest.Compare("Custom Start") )
632
		else if ( sRest.Compare("Start") || sRest.Compare("Custom Start") )
636
			this->SetCustomStart();
633
			this->SetCustomStart();
637
		else if ( rest.Compare("Patch") || rest.Compare("Patch Mod") )
634
		else if ( sRest.Compare("Patch") || sRest.Compare("Patch Mod") )
638
			this->SetPatch();
635
			this->SetPatch();
639
		else
636
		else
640
		{
637
		{
641
			int check = rest;
638
			int check = sRest;
642
			if ( check || rest == "0" )
639
			if ( check || sRest == "0" )
643
				m_iScriptType = check;
640
				m_iScriptType = check;
644
			else
641
			else
645
			{
642
			{
646
				m_iScriptType = CSpkFile::ConvertScriptType(rest);
643
				m_iScriptType = CSpkFile::ConvertScriptType(sRest);
647
				if ( m_iScriptType == -1 )
644
				if ( m_iScriptType == -1 )
648
					m_sScriptType = rest;
645
					m_sScriptType = sRest;
649
			}
646
			}
650
		}
647
		}
651
	}
648
	}
652
	else if ( first.Compare("AnotherMod") )
649
	else if ( sFirst.Compare("AnotherMod") )
653
	{
650
	{
654
		m_sOtherName = rest.token("|", 1);
651
		m_sOtherName = sRest.token("|", 1);
655
		m_sOtherAuthor = rest.tokens("|", 2);
652
		m_sOtherAuthor = sRest.tokens("|", 2);
656
	}
653
	}
657
	else if ( first.Compare("WareName") || first.Compare("WareDesc") )
654
	else if ( sFirst.Compare("WareName") || sFirst.Compare("WareDesc") )
658
	{
655
	{
659
		// find the ware to use
656
		// find the ware to use
660
		SWares *useWare = m_pLastWare;
657
		SWares *useWare = m_pLastWare;
661
		Utils::String id = rest.token(" ", 1);
658
		Utils::String id = sRest.token(" ", 1);
662
		for ( CListNode<SWares> *wNode = m_lWares.Front(); wNode; wNode = wNode->next() )
659
		for ( CListNode<SWares> *wNode = m_lWares.Front(); wNode; wNode = wNode->next() )
663
		{
660
		{
664
			if ( wNode->Data()->sID.Compare(id.c_str()) )
661
			if ( wNode->Data()->sID.Compare(id.c_str()) )
665
			{
662
			{
666
				useWare = wNode->Data();
663
				useWare = wNode->Data();
Line 669... Line 666...
669
		}
666
		}
670
 
667
 
671
		// check if we have the id already
668
		// check if we have the id already
672
		if ( useWare )
669
		if ( useWare )
673
		{
670
		{
674
			int lang = rest.token(" ", 2);
671
			int lang = sRest.token(" ", 2);
675
			SWaresText *wt = NULL;
672
			SWaresText *wt = NULL;
676
			for ( CListNode<SWaresText> *tNode = useWare->lText.Front(); tNode; tNode = tNode->next() )
673
			for ( CListNode<SWaresText> *tNode = useWare->lText.Front(); tNode; tNode = tNode->next() )
677
			{
674
			{
678
				if ( tNode->Data()->iLang == lang )
675
				if ( tNode->Data()->iLang == lang )
679
				{
676
				{
Line 687... Line 684...
687
				wt = new SWaresText;
684
				wt = new SWaresText;
688
				wt->iLang = lang;
685
				wt->iLang = lang;
689
				useWare->lText.push_back(wt);
686
				useWare->lText.push_back(wt);
690
			}
687
			}
691
 
688
 
692
			if ( first.Compare("WareName") )
689
			if ( sFirst.Compare("WareName") )
693
				wt->sName = rest.tokens(" ", 3);
690
				wt->sName = sRest.tokens(" ", 3);
694
			else
691
			else
695
				wt->sDesc = rest.tokens(" ", 3);
692
				wt->sDesc = sRest.tokens(" ", 3);
696
		}
693
		}
697
	}
694
	}
698
	else if ( first.Left(4).Compare("Ware") )
695
	else if ( sFirst.left(4).Compare("Ware") )
699
	{
696
	{
700
		SWares *ware = new SWares;
697
		SWares *ware = new SWares;
701
		ware->iTextID = -1;
698
		ware->iTextID = -1;
702
		ware->iTextPage = 0;
699
		ware->iTextPage = 0;
703
		ware->cType = first[4];
700
		ware->cType = sFirst[4];
704
		ware->iPrice = rest.token(" ", 2);
701
		ware->iPrice = sRest.token(" ", 2);
705
		ware->iSize = rest.token(" ", 3);
702
		ware->iSize = sRest.token(" ", 3);
706
		ware->iVolumn = rest.token(" ", 4);
703
		ware->iVolumn = sRest.token(" ", 4);
707
		ware->sID = rest.token(" ", 1);
704
		ware->sID = sRest.token(" ", 1);
708
		ware->iNotority = rest.token(" ", 5);
705
		ware->iNotority = sRest.token(" ", 5);
709
		if ( !rest.token(" ", 6).empty() )
706
		if ( !sRest.token(" ", 6).empty() )
710
		{
707
		{
711
			ware->iTextID = rest.token(" ", 6).token(",", 2);
708
			ware->iTextID = sRest.token(" ", 6).token(",", 2);
712
			ware->iTextPage = rest.token(" ", 6).token(",", 1);
709
			ware->iTextPage = sRest.token(" ", 6).token(",", 1);
713
		}
710
		}
714
		m_lWares.push_back ( ware );
711
		m_lWares.push_back ( ware );
715
		m_pLastWare = ware;
712
		m_pLastWare = ware;
716
	}
713
	}
717
 
714
 
718
	else if ( CBaseFile::LoadPackageData(first, rest) )
715
	else if ( CBaseFile::LoadPackageData(sFirst, sRest) )
719
		return true;
716
		return true;
720
	else
717
	else
721
		return false;
718
		return false;
722
 
719
 
723
	return true;
720
	return true;
Line 959... Line 956...
959
		CLog::logf(CLog::Log_IO, "Unable to open file: %s", sOldFilename.c_str());
956
		CLog::logf(CLog::Log_IO, "Unable to open file: %s", sOldFilename.c_str());
960
		return false;
957
		return false;
961
	}
958
	}
962
 
959
 
963
	// read the first 3 charaters to check if its using the original "HiP" compression
960
	// read the first 3 charaters to check if its using the original "HiP" compression
964
	CyString check = (char)fgetc ( id );
961
	Utils::String check((char)fgetc(id));
965
	check += (char)fgetc ( id );
962
	check += (char)fgetc ( id );
966
	check += (char)fgetc ( id );
963
	check += (char)fgetc ( id );
967
 
964
 
968
	CyString removeFile;
965
	Utils::String removeFile;
969
 
966
 
970
	unsigned char *uncomprData = NULL;
967
	unsigned char *uncomprData = NULL;
971
	unsigned char *data = NULL;
968
	unsigned char *data = NULL;
972
	long len = 0, newlen = 0;
969
	long len = 0, newlen = 0;
973
 
970
 
Line 1024... Line 1021...
1024
	#endif
1021
	#endif
1025
	}
1022
	}
1026
 
1023
 
1027
	*pLen = newlen;
1024
	*pLen = newlen;
1028
 
1025
 
1029
	if ( !removeFile.Empty() ) {
1026
	if ( !removeFile.empty() ) {
1030
		CFileIO(removeFile).Remove();
1027
		CFileIO(removeFile).Remove();
1031
	}
1028
	}
1032
 
1029
 
1033
	return uncomprData;
1030
	return uncomprData;
1034
}
1031
}
Line 1232... Line 1229...
1232
		file->ReadFromData ( (char *)d, size );
1229
		file->ReadFromData ( (char *)d, size );
1233
		d += size;
1230
		d += size;
1234
	}
1231
	}
1235
	else
1232
	else
1236
	{
1233
	{
1237
		CyString readData;
1234
		Utils::String readData;
1238
		d = LineByLineRead ( d, sEnd, &readData );
1235
		d = LineByLineRead ( d, sEnd, &readData );
1239
		file->ReadFromData ( (char *)readData.c_str(), (long)readData.Length() );
1236
		file->ReadFromData ( (char *)readData.c_str(), (long)readData.length() );
1240
	}
1237
	}
1241
 
1238
 
1242
	// setup the file
1239
	// setup the file
1243
	file->SetName ( filename );
1240
	file->SetName ( filename );
1244
	file->SetFileType ( iType );
1241
	file->SetFileType ( iType );