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 45... Line 45...
45
	if ( !searchmask.Empty() )
45
	if ( !searchmask.Empty() )
46
		printf ( "(%s)", searchmask.c_str() );
46
		printf ( "(%s)", searchmask.c_str() );
47
	printf ( "\n");
47
	printf ( "\n");
48
 
48
 
49
	CCatFile catfile;
49
	CCatFile catfile;
50
	int err = catfile.Open ( filename, "", CATREAD_CATDECRYPT );
50
	int err = catfile.open(filename.ToString(), "", CATREAD_CATDECRYPT);
51
 
51
 
52
	if ( err == CATERR_NONE )
52
	if ( err == CATERR_NONE )
53
	{
53
	{
54
		printf ( "Opened file\n" );
54
		printf ( "Opened file\n" );
55
		for (unsigned int i = 0; i < catfile.GetNumFiles(); i++)
55
		for (unsigned int i = 0; i < catfile.GetNumFiles(); i++)
Line 79... Line 79...
79
 
79
 
80
void ExtractFile ( CyString filename, CyString to, bool preserve )
80
void ExtractFile ( CyString filename, CyString to, bool preserve )
81
{
81
{
82
	if ( !filename.IsIn ( "::" ) ) return;
82
	if ( !filename.IsIn ( "::" ) ) return;
83
 
83
 
84
	CyString catfile = filename.GetToken ( ";::", 1, 1 );
84
	Utils::String catfile = filename.GetToken ( ";::", 1, 1 ).ToString();
85
	CyString filemask = filename.GetToken ( ";::", 2, 2 );
85
	Utils::String filemask = filename.GetToken ( ";::", 2, 2 ).ToString();
86
 
86
 
87
	CCatFile cat;
87
	CCatFile cat;
88
	int err = cat.Open ( catfile, "", CATREAD_DAT );
88
	int err = cat.open(catfile, "", CATREAD_DAT);
89
	if ( err )
89
	if ( err )
90
	{
90
	{
91
		PrintError ( err );
91
		PrintError ( err );
92
		return;
92
		return;
93
	}
93
	}
Line 108... Line 108...
108
	}
108
	}
109
 
109
 
110
	//TODO: add proper file mask for extracting
110
	//TODO: add proper file mask for extracting
111
	//CyStringList *fileList = FindFiles(filemask);
111
	//CyStringList *fileList = FindFiles(filemask);
112
	CyStringList *fileList = new CyStringList;
112
	CyStringList *fileList = new CyStringList;
113
	fileList->PushBack(filemask);
113
	fileList->PushBack(CyString(filemask));
114
	if ( !fileList || fileList->Empty() )
114
	if ( !fileList || fileList->Empty() )
115
	{
115
	{
116
		if ( fileList ) delete fileList;
116
		if ( fileList ) delete fileList;
117
		printf ( "Error: unable to find any files matching: %s\n", filemask.c_str() );
117
		printf ( "Error: unable to find any files matching: %s\n", filemask.c_str() );
118
		return;
118
		return;
Line 130... Line 130...
130
	delete fileList;
130
	delete fileList;
131
}
131
}
132
 
132
 
133
void AppendFile ( CyString C_File, CyString filepattern )
133
void AppendFile ( CyString C_File, CyString filepattern )
134
{
134
{
135
	CyString catfile;
135
	Utils::String catfile;
136
	CyString file;
136
	Utils::String file;
137
 
137
 
138
	C_File = C_File.FindReplace("\\", "/");
138
	C_File = C_File.FindReplace("\\", "/");
139
 
139
 
140
	bool doFile = false;
140
	bool doFile = false;
141
	if ( !C_File.IsIn ( "::" ) )
141
	if ( !C_File.IsIn ( "::" ) )
142
	{
142
	{
143
		catfile = C_File;
143
		catfile = C_File.ToString();
144
		doFile = true;
144
		doFile = true;
145
	}
145
	}
146
	else
146
	else
147
	{
147
	{
148
		catfile = C_File.GetToken ( "::", 1, 1 );
148
		catfile = C_File.GetToken ( "::", 1, 1 ).ToString();
149
		file = C_File.GetToken ( "::", 2, 2 );
149
		file = C_File.GetToken ( "::", 2, 2 ).ToString();
150
	}
150
	}
151
 
151
 
152
	CyStringList *list = FindFiles(filepattern);
152
	CyStringList *list = FindFiles(filepattern);
153
	if ( !list || !list->Count() )
153
	if ( !list || !list->Count() )
154
	{
154
	{
155
		printf("Error: no files found to add: %s\n", filepattern.c_str());
155
		printf("Error: no files found to add: %s\n", filepattern.c_str());
156
		return;
156
		return;
157
	}
157
	}
158
 
158
 
159
	CCatFile cat;
159
	CCatFile cat;
160
	int err = cat.Open ( catfile, "", CATREAD_CATDECRYPT );
160
	int err = cat.open(catfile, "", CATREAD_CATDECRYPT);
161
	if ( err )
161
	if ( err )
162
	{
162
	{
163
		delete list;
163
		delete list;
164
		PrintError ( err );
164
		PrintError ( err );
165
		return;
165
		return;
166
	}
166
	}
167
 
167
 
168
	for ( SStringList *fname = list->Head(); fname; fname = fname->next )
168
	for ( SStringList *fname = list->Head(); fname; fname = fname->next )
169
	{
169
	{
170
		CyString filename = fname->str;
170
		Utils::String filename = fname->str.ToString();
171
		if ( doFile )
171
		if ( doFile )
172
			file = filename;
172
			file = filename;
173
 
173
 
174
		if ( !file.IsIn('.') )
174
		if (!file.isin('.'))
175
		{
175
		{
176
			if ( file[file.Length() - 1] != '/' )
176
			if ( file[file.length() - 1] != '/' )
177
				file += '/';
177
				file += '/';
178
			file += CFileIO(filename).GetFilename();
178
			file += CFileIO(filename).filename();
179
		}
179
		}
180
 
180
 
181
		if ( cat.AppendFile(filename.ToString(), file.ToString() ) )
181
		if ( cat.AppendFile(filename, file))
182
			printf ( "File %s has beed added to: %s::%s\n", filename.c_str(), catfile.c_str(), file.c_str() );
182
			printf ( "File %s has beed added to: %s::%s\n", filename.c_str(), catfile.c_str(), file.c_str() );
183
		else
183
		else
184
			printf ( "Error: Unable to add file: %s\n", filename.c_str());
184
			printf ( "Error: Unable to add file: %s\n", filename.c_str());
185
	}
185
	}
186
 
186
 
Line 189... Line 189...
189
 
189
 
190
void RemoveFile ( CyString C_File, CyString remfile )
190
void RemoveFile ( CyString C_File, CyString remfile )
191
{
191
{
192
	// first open the cat file
192
	// first open the cat file
193
	CCatFile cat;
193
	CCatFile cat;
194
	int err = cat.Open ( C_File, "", CATREAD_CATDECRYPT );
194
	int err = cat.open(C_File.ToString(), "", CATREAD_CATDECRYPT);
195
	if ( err )
195
	if ( err )
196
	{
196
	{
197
		PrintError ( err );
197
		PrintError ( err );
198
		return;
198
		return;
199
	}
199
	}