Subversion Repositories spk

Rev

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

Rev 305 Rev 312
Line 217... Line 217...
217
		return;
217
		return;
218
	}
218
	}
219
 
219
 
220
	for(auto itr = list.first(); itr; itr = list.next())
220
	for(auto itr = list.first(); itr; itr = list.next())
221
	{
221
	{
222
		Utils::WString filename = CFileIO(file).dir() + L"/" + itr->str;
222
		Utils::WString filename = itr->str;
223
 
223
 
224
		C_File f(filename);
224
		C_File f(filename);
225
		if (!f.CheckValidFilePointer())
225
		if (!f.CheckValidFilePointer())
226
		{
226
		{
227
			CFileIO File((file.contains(L":")) ? file : g_dir + L"/" + file);
227
			CFileIO File((file.contains(L":")) ? file : g_dir + L"/" + file);
Line 235... Line 235...
235
			wprintf(L"Error: %s doesn't exists\n", filename.c_str() );
235
			wprintf(L"Error: %s doesn't exists\n", filename.c_str() );
236
		else if ( !f.ReadFromFile() )
236
		else if ( !f.ReadFromFile() )
237
			wprintf(L"Error: unable to open file: %s\n", filename.c_str() );
237
			wprintf(L"Error: unable to open file: %s\n", filename.c_str() );
238
		else
238
		else
239
		{
239
		{
240
			f.UnPCKFile();
240
			if(!f.UnPCKFile())
-
 
241
				wprintf(L"Error: unable to unpack file: %s\n", filename.c_str());
-
 
242
			else
-
 
243
			{
241
			if (tofile.empty())
244
				if (tofile.empty())
242
				f.changeFileExt(ext.empty() ? L"xml" : ext);
245
					f.changeFileExt(ext.empty() ? L"xml" : ext);
243
			else if ( tofile.left(2) == L";*." )
246
				else if (tofile.left(2) == L";*.")
244
				f.changeFileExt(CFileIO(tofile).extension().toString());
247
					f.changeFileExt(CFileIO(tofile).extension().toString());
245
			else
248
				else
246
				f.setFilename(tofile);
249
					f.setFilename(tofile);
247
 
250
 
248
			if ( !f.writeFilePointer() )
251
				if (!f.writeFilePointer())
249
				wprintf(L"Error: unable to write file: %s\n", tofile.c_str() );
252
					wprintf(L"Error: unable to write file: %s\n", tofile.c_str());
250
			else
253
				else
251
				wprintf(L"%s has been unpacked to %s\n", oldFilename.c_str(), f.filename().c_str() );
254
					wprintf(L"%s has been unpacked to %s\n", oldFilename.c_str(), f.filename().c_str());
-
 
255
			}
252
		}
256
		}
253
	}
257
	}
254
}
258
}
255
 
259
 
256
void PackFile(const Utils::WString &file, const Utils::WString &tofile)
260
void PackFile(const Utils::WString &file, const Utils::WString &tofile)
Line 261... Line 265...
261
		wprintf(L"Error: no files found to pack: %s\n", file.c_str());
265
		wprintf(L"Error: no files found to pack: %s\n", file.c_str());
262
		return;
266
		return;
263
	}
267
	}
264
 
268
 
265
	for(auto itr = list.first(); itr; itr = list.next())
269
	for(auto itr = list.first(); itr; itr = list.next())
266
	{
270
	{
267
		Utils::WString filename = CFileIO(file).dir() + L"/" + itr->str;
271
		Utils::WString filename = itr->str;
268
 
272
 
269
		C_File f(filename);
273
		C_File f(filename);
270
		if ( !f.CheckValidFilePointer() )
274
		if ( !f.CheckValidFilePointer() )
271
			wprintf(L"Error: %s doesn't exists\n", filename.c_str() );
275
			wprintf(L"Error: %s doesn't exists\n", filename.c_str() );
272
		else if ( !f.ReadFromFile() )
276
		else if ( !f.ReadFromFile() )
Line 292... Line 296...
292
			if ( !f.writeFilePointer() )
296
			if ( !f.writeFilePointer() )
293
				wprintf(L"Error: unable to write file: %s\n", tofile.c_str() );
297
				wprintf(L"Error: unable to write file: %s\n", tofile.c_str() );
294
			else
298
			else
295
				wprintf(L"%s has been packed to %s\n", file.c_str(), f.filename().c_str() );
299
				wprintf(L"%s has been packed to %s\n", file.c_str(), f.filename().c_str() );
296
		}
300
		}
297
	}
301
	}
298
}
302
}
299
 
303
 
300
void PrintSyntax(const Utils::WString &cmd)
304
void PrintSyntax(const Utils::WString &cmd)
301
{
305
{
302
	wprintf(L"Syntax: %s <flags> [arguments]\n", cmd.c_str() );
306
	wprintf(L"Syntax: %s <flags> [arguments]\n", cmd.c_str() );
303
	wprintf(L"Flags:\n");
307
	wprintf(L"Flags:\n");
Line 324... Line 328...
324
	printf ( "\nCATPCK Tool V1.21 27/03/2011 (SPK: %.2f) Created by Cycrow\n\n", GetLibraryVersion() );
328
	printf ( "\nCATPCK Tool V1.21 27/03/2011 (SPK: %.2f) Created by Cycrow\n\n", GetLibraryVersion() );
325
 
329
 
326
	// parse the cmd name
330
	// parse the cmd name
327
	Utils::CommandLine cmd(argc, argv);
331
	Utils::CommandLine cmd(argc, argv);
328
	g_dir = cmd.cmdDir();
332
	g_dir = cmd.cmdDir();
329
 
-
 
330
	if (g_dir.empty() || !g_dir.contains("/"))
-
 
331
	{
-
 
332
	    #ifdef _WIN32
-
 
333
		g_dir = Utils::WString(_getcwd(NULL, 0));
-
 
334
		#else
-
 
335
		g_dir = Utils::WString(getcwd(NULL, 0));
-
 
336
		#endif
-
 
337
		if (g_dir.empty())
-
 
338
			g_dir = L"./";
-
 
339
	}
-
 
340
 
333
 
341
	if ( argc < 2 )
334
	if ( argc < 2 )
342
		PrintSyntax(cmd.cmdName());
335
		PrintSyntax(cmd.cmdName());
343
	else
336
	else
344
	{
337
	{