Subversion Repositories spk

Rev

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

Rev 124 Rev 125
Line 41... Line 41...
41
	_lFiles->clear();
41
	_lFiles->clear();
42
}
42
}
43
 
43
 
44
bool CCatFile::IsAddonDir(CyString dir)
44
bool CCatFile::IsAddonDir(CyString dir)
45
{
45
{
46
	CyString d = dir;
46
	Utils::String d = dir.ToString();
47
	d = d.FindReplace("\\", "/");
47
	d = d.findReplace("\\", "/");
48
	d = d.GetToken("/", 1, 1);
48
	d = d.token("/", 1);
49
 
49
 
50
	if ( d.Compare("types") )
50
	if ( d.Compare("types") )
51
		return true;
51
		return true;
52
	if ( d.Compare("t") )
52
	if ( d.Compare("t") )
53
		return true;
53
		return true;
Line 64... Line 64...
64
{
64
{
65
	if ( error == CATERR_NONE ) return true;
65
	if ( error == CATERR_NONE ) return true;
66
	if ( allowCreate && error == CATERR_CREATED ) return true;
66
	if ( allowCreate && error == CATERR_CREATED ) return true;
67
	return false;
67
	return false;
68
}
68
}
69
int CCatFile::Open ( CyString sCatfile, CyString addon, int readtype, bool create )
69
int CCatFile::open(const Utils::String &sCatfile, const Utils::String &addon, int readtype, bool create)
70
{
70
{
71
	Utils::String catfile = sCatfile.ToString();
71
	Utils::String catfile = sCatfile;
72
 
72
 
73
	m_bCreate = false;
73
	m_bCreate = false;
74
 
-
 
75
	Utils::String datfile;
74
	Utils::String datfile;
76
	if ( !catfile.right(4).Compare(".cat") ) {
75
	if ( !catfile.right(4).Compare(".cat") ) {
77
		datfile = catfile + ".dat";
76
		datfile = catfile + ".dat";
78
		catfile += ".cat";
77
		catfile += ".cat";
79
	}
78
	}
Line 141... Line 140...
141
		if ( !DecryptData () ) return CATERR_DECRYPT;
140
		if ( !DecryptData () ) return CATERR_DECRYPT;
142
		m_sData[File.fileSize()] = 0;
141
		m_sData[File.fileSize()] = 0;
143
		readFiles ();
142
		readFiles ();
144
	}
143
	}
145
 
144
 
146
	_sAddonDir = addon.ToString();
145
	_sAddonDir = addon;
147
 
146
 
148
	m_fCatFile.open ( catfile );
147
	m_fCatFile.open ( catfile );
149
 
148
 
150
	if ( readtype != CATREAD_JUSTCONTENTS ) {
149
	if ( readtype != CATREAD_JUSTCONTENTS ) {
151
		m_fDatFile.open ( datfile );
150
		m_fDatFile.open ( datfile );
Line 673... Line 672...
673
	return append;
672
	return append;
674
}
673
}
675
 
674
 
676
bool CCatFile::AddData ( CyString catfile, unsigned char *data, size_t size, CyString to, bool pck, bool create )
675
bool CCatFile::AddData ( CyString catfile, unsigned char *data, size_t size, CyString to, bool pck, bool create )
677
{
676
{
678
	int err = Open ( catfile, "", CATREAD_CATDECRYPT, create );
677
	int err = open(catfile.ToString(), "", CATREAD_CATDECRYPT, create);
679
	if ( (err != CATERR_NONE) && (err != CATERR_CREATED) )
678
	if ( (err != CATERR_NONE) && (err != CATERR_CREATED) )
680
		return false;
679
		return false;
681
 
680
 
682
	return AppendData ( data, size, to, pck );
681
	return AppendData ( data, size, to, pck );
683
}
682
}
Line 778... Line 777...
778
}
777
}
779
 
778
 
780
Utils::String CCatFile::RenameFileExtension(SInCatFile *f)
779
Utils::String CCatFile::RenameFileExtension(SInCatFile *f)
781
{
780
{
782
	CFileIO fo(f->sFile);
781
	CFileIO fo(f->sFile);
783
	Utils::String ext = fo.GetFileExtension ().lower().ToString();
782
	Utils::String ext = fo.extension().lower();
784
	if ( ext == "pck" )
783
	if ( ext == "pck" )
785
	{
784
	{
786
		Utils::String firstDir = f->sFile.findReplace("/", "\\").token("\\", 1).lower();
785
		Utils::String firstDir = f->sFile.findReplace("/", "\\").token("\\", 1).lower();
787
 
786
 
788
		if ( firstDir == "t" )
787
		if ( firstDir == "t" )
Line 1144... Line 1143...
1144
}
1143
}
1145
 
1144
 
1146
bool CCatFile::WriteFromCat ( CyString catfile, CyString file )
1145
bool CCatFile::WriteFromCat ( CyString catfile, CyString file )
1147
{
1146
{
1148
	CCatFile fcat;
1147
	CCatFile fcat;
1149
	if ( fcat.Open ( catfile, "", CATREAD_CATDECRYPT, false ) )
1148
	if ( fcat.open(catfile.ToString(), "", CATREAD_CATDECRYPT, false) )
1150
		return false;
1149
		return false;
1151
 
1150
 
1152
	return this->WriteFromCat(&fcat, file);
1151
	return this->WriteFromCat(&fcat, file);
1153
}
1152
}
1154
 
1153