Subversion Repositories spk

Rev

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

Rev 314 Rev 316
Line 40... Line 40...
40
			printf ( "Dat file size mismatch\n" );
40
			printf ( "Dat file size mismatch\n" );
41
			break;
41
			break;
42
	}
42
	}
43
}
43
}
44
 
44
 
45
void ListFiles (const Utils::WString &filename, const Utils::WString &searchmask )
45
void ListFiles(const Utils::CommandLine &cmd)
46
{
46
{
-
 
47
	const Utils::WString& filename = cmd.arg(1);
-
 
48
	const Utils::WString& searchmask = cmd.arg(2);
-
 
49
 
-
 
50
	CFileIO File(!filename.contains(L":") ? CDirIO(g_dir).file(filename) : filename);
-
 
51
	if(!File.exists())
-
 
52
		File.open(filename);
-
 
53
	if (!File.exists())
-
 
54
	{
-
 
55
		wprintf(L"Error: Cat file: %s, does not exist", filename.c_str());
-
 
56
		return;
-
 
57
	}
-
 
58
	
47
	wprintf(L"Listing files in %s...", filename.c_str() );
59
	wprintf(L"Listing files in %s...", filename.c_str());
48
	if (!searchmask.empty())
60
	if (!searchmask.empty())
49
		wprintf(L"(%s)", searchmask.c_str() );
61
		wprintf(L"(%s)", searchmask.c_str() );
50
	printf("\n");
62
	printf("\n");
51
 
63
 
52
	CCatFile catfile;
64
	CCatFile catfile;
53
	int err = catfile.open(filename, L"", CATREAD_CATDECRYPT);
65
	int err = catfile.open(File.fullFilename(), L"", CATREAD_CATDECRYPT);
54
 
66
 
-
 
67
	int listed = 0;
55
	if ( err == CATERR_NONE )
68
	if ( err == CATERR_NONE )
56
	{
69
	{
57
		printf ( "Opened file\n" );
70
		printf ( "Opened file\n" );
58
		for (unsigned int i = 0; i < catfile.GetNumFiles(); i++)
71
		for (unsigned int i = 0; i < catfile.GetNumFiles(); i++)
59
		{
72
		{
60
			SInCatFile *file = catfile.GetFile ( i );
73
			SInCatFile *file = catfile.GetFile ( i );
61
 
74
 
62
			if (!searchmask.empty())
75
			if (!searchmask.empty())
63
			{
76
			{
64
				if (!searchmask.match(file->sFile))
77
				if (!file->sFile.match(searchmask))
65
					continue;
78
					continue;
66
			}
79
			}
67
 
80
 
68
			wprintf(L"[%9s] %s\n", SPK::GetSizeString(static_cast<unsigned long>(file->lSize)).c_str(), file->sFile.c_str() );
81
			wprintf(L"[%9s] %s\n", SPK::GetSizeString(static_cast<unsigned long>(file->lSize)).c_str(), file->sFile.c_str() );
-
 
82
			++listed;
69
		}
83
		}
-
 
84
 
-
 
85
		if (!searchmask.empty())
-
 
86
			wprintf(L"\nListed Files: [%d/%d]", listed, static_cast<int>(catfile.GetNumFiles()));
70
	}
87
	}
71
	else
88
	else
72
		PrintError ( err );
89
		PrintError ( err );
73
}
90
}
74
 
91
 
Line 201... Line 218...
201
		if (doFile)			
218
		if (doFile)			
202
			toFile = File.dirIO().relativePath(filename);;
219
			toFile = File.dirIO().relativePath(filename);;
203
 
220
 
204
		if (!toFile.contains(L"."))
221
		if (!toFile.contains(L"."))
205
		{
222
		{
206
			if (toFile[toFile.length() - 1] != L'/')
223
			if (toFile[static_cast<unsigned long>(toFile.length() - 1)] != L'/')
207
				toFile += L"/";
224
				toFile += L"/";
208
			toFile += CFileIO(filename).filename();
225
			toFile += CFileIO(filename).filename();
209
		}
226
		}
210
 
227
 
211
		++added;
228
		++added;
Line 356... Line 373...
356
	wprintf(L"\t\tPacks a file, ie from xml/txt to pck\n");
373
	wprintf(L"\t\tPacks a file, ie from xml/txt to pck\n");
357
}
374
}
358
 
375
 
359
int main ( int argc, char **argv )
376
int main ( int argc, char **argv )
360
{
377
{
361
	printf ( "\nCATPCK Tool V1.21 27/03/2011 (SPK: %.2f) Created by Cycrow\n\n", GetLibraryVersion() );
378
	printf ( "\nCATPCK Tool V1.22 17/05/2025 (SPK: %.2f) Created by Cycrow\n\n", GetLibraryVersion() );
362
 
379
 
363
	// parse the cmd name
380
	// parse the cmd name
364
	Utils::CommandLine cmd(argc, argv);
381
	Utils::CommandLine cmd(argc, argv);
365
	g_dir = cmd.cmdDir();
382
	g_dir = cmd.cmdDir();
366
 
383
 
Line 372... Line 389...
372
 
389
 
373
		auto& args = cmd.args();
390
		auto& args = cmd.args();
374
 
391
 
375
		if ( (command == L"-l") || (command == L"-list") )
392
		if ( (command == L"-l") || (command == L"-list") )
376
		{
393
		{
377
			if ( args.size() < 2 )
394
			if (cmd.argCount() < 2)
378
				wprintf(L"Syntax: %s -l <filename> [filemask]\n\tLists the contents of the cat file\n", cmd.cmdName().c_str());
395
				wprintf(L"Syntax: %s -l <filename> [filemask]\n\tLists the contents of the cat file\n", cmd.cmdName().c_str());
379
			else if ( args.size() < 3)
-
 
380
				ListFiles(args[1], Utils::WString(L""));
-
 
381
			else
396
			else
382
				ListFiles(args[1], args[2]);
397
				ListFiles(cmd);
383
		}
398
		}
384
		else if ( (command == L"-x") || (command == L"-extract") || (command == L"-xp") || (command == L"-extractpreserve") )
399
		else if ( (command == L"-x") || (command == L"-extract") || (command == L"-xp") || (command == L"-extractpreserve") )
385
		{
400
		{
386
			if ( args.size() < 2 )
401
			if ( args.size() < 2 )
387
				wprintf(L"Syntax: %s %s <catfile::filename> [dir]\n\tExtracts a file from the cat archive\n", cmd.cmdName().c_str(), command.c_str() );
402
				wprintf(L"Syntax: %s %s <catfile::filename> [dir]\n\tExtracts a file from the cat archive\n", cmd.cmdName().c_str(), command.c_str() );