Subversion Repositories spk

Rev

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

Rev 181 Rev 185
Line 204... Line 204...
204
 
204
 
205
	if (cat.removeFile(f))
205
	if (cat.removeFile(f))
206
		printf ( "File has been removed from archive\n" );
206
		printf ( "File has been removed from archive\n" );
207
}
207
}
208
 
208
 
209
void UnpackFile ( CyString file, CyString tofile )
209
void UnpackFile(const Utils::String &file, const Utils::String &tofile )
210
{
210
{
211
	Utils::CStringList list;
211
	Utils::CStringList list;
212
	if(!findFiles(list, file.ToString()) || !list.size())
212
	if(!findFiles(list, file) || !list.size())
213
	{
213
	{
214
		printf("Error: no files found to unpack: %s\n", file.c_str());
214
		printf("Error: no files found to unpack: %s\n", file.c_str());
215
		return;
215
		return;
216
	}
216
	}
217
 
217
 
Line 225... Line 225...
225
		else if ( !f.ReadFromFile() )
225
		else if ( !f.ReadFromFile() )
226
			printf("Error: unable to open file: %s\n", filename.c_str() );
226
			printf("Error: unable to open file: %s\n", filename.c_str() );
227
		else
227
		else
228
		{
228
		{
229
			f.UnPCKFile();
229
			f.UnPCKFile();
230
			if ( tofile.Empty() )
230
			if ( tofile.empty() )
231
				f.changeFileExt("xml");
231
				f.changeFileExt("xml");
232
			else if ( tofile.Left(2) == "*." )
232
			else if ( tofile.left(2) == "*." )
233
				f.changeFileExt(CFileIO(tofile).extension());
233
				f.changeFileExt(CFileIO(tofile).extension());
234
			else
234
			else
235
				f.setFilename(tofile.ToString());
235
				f.setFilename(tofile);
236
 
236
 
237
			if ( !f.writeFilePointer() )
237
			if ( !f.writeFilePointer() )
238
				printf("Error: unable to write file: %s\n", tofile.c_str() );
238
				printf("Error: unable to write file: %s\n", tofile.c_str() );
239
			else
239
			else
240
				printf("%s has been unpacked to %s\n", file.c_str(), f.filename().c_str() );
240
				printf("%s has been unpacked to %s\n", file.c_str(), f.filename().c_str() );
241
		}
241
		}
242
	}
242
	}
243
}
243
}
244
 
244
 
245
void PackFile ( CyString file, CyString tofile )
245
void PackFile(const Utils::String &file, const Utils::String &tofile)
246
{
246
{
247
	Utils::CStringList list;
247
	Utils::CStringList list;
248
	if(!findFiles(list, file.ToString()) || !list.size())
248
	if(!findFiles(list, file) || !list.size())
249
	{
249
	{
250
		printf("Error: no files found to pack: %s\n", file.c_str());
250
		printf("Error: no files found to pack: %s\n", file.c_str());
251
		return;
251
		return;
252
	}
252
	}
253
 
253
 
Line 262... Line 262...
262
			printf("Error: unable to open file: %s\n", filename.c_str() );
262
			printf("Error: unable to open file: %s\n", filename.c_str() );
263
		else if ( !f.PCKFile() )
263
		else if ( !f.PCKFile() )
264
			printf("Error: unable to pack file: %s\n", filename.c_str() );
264
			printf("Error: unable to pack file: %s\n", filename.c_str() );
265
		else
265
		else
266
		{
266
		{
267
			if ( tofile.Empty() )
267
			if ( tofile.empty() )
268
			{
268
			{
269
				if ( f.checkFileExt("bob") )
269
				if ( f.checkFileExt("bob") )
270
					f.changeFileExt("pbb");
270
					f.changeFileExt("pbb");
271
				else if ( f.checkFileExt("bod") )
271
				else if ( f.checkFileExt("bod") )
272
					f.changeFileExt("pbd");
272
					f.changeFileExt("pbd");
273
				else
273
				else
274
					f.changeFileExt("pck");
274
					f.changeFileExt("pck");
275
			}
275
			}
276
			else if ( tofile.Left(2) == "*." )
276
			else if ( tofile.left(2) == "*." )
277
				f.changeFileExt(tofile.Right(3).ToString());
277
				f.changeFileExt(tofile.right(3));
278
			else
278
			else
279
				f.setFilename(tofile.ToString());
279
				f.setFilename(tofile);
280
 
280
 
281
			if ( !f.writeFilePointer() )
281
			if ( !f.writeFilePointer() )
282
				printf("Error: unable to write file: %s\n", tofile.c_str() );
282
				printf("Error: unable to write file: %s\n", tofile.c_str() );
283
			else
283
			else
284
				printf("%s has been packed to %s\n", file.c_str(), f.filename().c_str() );
284
				printf("%s has been packed to %s\n", file.c_str(), f.filename().c_str() );
Line 380... Line 380...
380
		else if ( (command == "-u") || (command == "-unpack") )
380
		else if ( (command == "-u") || (command == "-unpack") )
381
		{
381
		{
382
			if ( argc < 3 )
382
			if ( argc < 3 )
383
				printf ( "Syntax: %s -u <filename> [to]\n\tUnpacks a file", cmd.c_str() );
383
				printf ( "Syntax: %s -u <filename> [to]\n\tUnpacks a file", cmd.c_str() );
384
			else if ( argc < 4 )
384
			else if ( argc < 4 )
385
				UnpackFile ( CyString(argv[2]), CyString("") );
385
				UnpackFile(argv[2], "" );
386
			else
386
			else
387
				UnpackFile ( CyString(argv[2]), CyString(argv[3]) );
387
				UnpackFile(argv[2], argv[3]);
388
		}
388
		}
389
		else if ( (command == "-p") || (command == "-pack") )
389
		else if ( (command == "-p") || (command == "-pack") )
390
		{
390
		{
391
			if ( argc < 3 )
391
			if ( argc < 3 )
392
				printf ( "Syntax: %s -p <filename> [to]\n\tPacks a file to .pck", cmd.c_str() );
392
				printf ( "Syntax: %s -p <filename> [to]\n\tPacks a file to .pck", cmd.c_str() );
393
			else if ( argc < 4 )
393
			else if ( argc < 4 )
394
				PackFile ( CyString(argv[2]), CyString("") );
394
				PackFile(argv[2], "");
395
			else
395
			else
396
				PackFile ( CyString(argv[2]), CyString(argv[3]) );
396
				PackFile(argv[2], argv[3]);
397
		}
397
		}
398
		else
398
		else
399
		{
399
		{
400
			printf("Invalaid flag: %s\n\n", command.c_str());
400
			printf("Invalaid flag: %s\n\n", command.c_str());
401
			PrintSyntax(cmd);
401
			PrintSyntax(cmd);