@@ -272,9 +272,9 @@ typedef enum {
272
272
int main (int argc , char * argv [])
273
273
{
274
274
sys_output_init ();
275
- sys_output ("pkg2zip v1.8\n" );
276
275
277
276
int zipped = 1 ;
277
+ int listing = 0 ;
278
278
int cso = 0 ;
279
279
const char * pkg_arg = NULL ;
280
280
const char * zrif_arg = NULL ;
@@ -284,6 +284,10 @@ int main(int argc, char* argv[])
284
284
{
285
285
zipped = 0 ;
286
286
}
287
+ else if (strcmp (argv [i ], "-l" ) == 0 )
288
+ {
289
+ listing = 1 ;
290
+ }
287
291
else if (strncmp (argv [i ], "-c" , 2 ) == 0 )
288
292
{
289
293
if (argv [i ][2 ] != 0 )
@@ -305,14 +309,20 @@ int main(int argc, char* argv[])
305
309
}
306
310
}
307
311
}
308
-
312
+ if (listing == 0 )
313
+ {
314
+ sys_output ("pkg2zip v1.8\n" );
315
+ }
309
316
if (pkg_arg == NULL )
310
317
{
311
318
fprintf (stderr , "ERROR: no pkg file specified\n" );
312
- sys_error ("Usage: %s [-x] [-c[N]] file.pkg [zRIF]\n" , argv [0 ]);
319
+ sys_error ("Usage: %s [-x] [-l] [- c[N]] file.pkg [zRIF]\n" , argv [0 ]);
313
320
}
314
321
315
- sys_output ("[*] loading...\n" );
322
+ if (listing == 0 )
323
+ {
324
+ sys_output ("[*] loading...\n" );
325
+ }
316
326
317
327
uint64_t pkg_size ;
318
328
sys_file pkg = sys_open (pkg_arg , & pkg_size );
@@ -496,39 +506,67 @@ int main(int argc, char* argv[])
496
506
type_str = content_type == 0xe ? "PSP-Go" : content_type == 0xf ? "PSP-Mini" : "PSP-NeoGeo" ;
497
507
}
498
508
snprintf (root , sizeof (root ), "%s [%.9s] [%s]%s" , title , id , type_str , ext );
499
- sys_output ("[*] unpacking %s\n" , type_str );
509
+ if (listing == 0 )
510
+ {
511
+ sys_output ("[*] unpacking %s\n" , type_str );
512
+ }
500
513
}
501
514
else if (type == PKG_TYPE_PSX )
502
515
{
503
516
snprintf (root , sizeof (root ), "%s [%.9s] [PSX]%s" , title , id , ext );
504
- sys_output ("[*] unpacking PSX\n" );
517
+ if (listing == 0 )
518
+ {
519
+ sys_output ("[*] unpacking PSX\n" );
520
+ }
505
521
}
506
522
else if (type == PKG_TYPE_VITA_DLC )
507
523
{
508
524
snprintf (root , sizeof (root ), "%s [%.9s] [%s] [DLC-%s]%s" , title , id , get_region (id ), id2 , ext );
509
- sys_output ("[*] unpacking Vita DLC\n" );
525
+ if (listing == 0 )
526
+ {
527
+ sys_output ("[*] unpacking Vita DLC\n" );
528
+ }
510
529
}
511
530
else if (type == PKG_TYPE_VITA_PATCH )
512
531
{
513
532
snprintf (root , sizeof (root ), "%s [%.9s] [%s] [PATCH] [v%s]%s" , title , id , get_region (id ), pkg_version , ext );
514
- sys_output ("[*] unpacking Vita PATCH\n" );
533
+ if (listing == 0 )
534
+ {
535
+ sys_output ("[*] unpacking Vita PATCH\n" );
536
+ }
515
537
}
516
538
else if (type == PKG_TYPE_VITA_PSM )
517
539
{
518
540
snprintf (root , sizeof (root ), "%.9s [%s] [PSM]%s" , id , get_region (id ), ext );
519
- sys_output ("[*] unpacking Vita PSM\n" );
541
+ if (listing == 0 )
542
+ {
543
+ sys_output ("[*] unpacking Vita PSM\n" );
544
+ }
520
545
}
521
546
else if (type == PKG_TYPE_VITA_APP )
522
547
{
523
548
snprintf (root , sizeof (root ), "%s [%.9s] [%s]%s" , title , id , get_region (id ), ext );
524
- sys_output ("[*] unpacking Vita APP\n" );
549
+ if (listing == 0 )
550
+ {
551
+ sys_output ("[*] unpacking Vita APP\n" );
552
+ }
525
553
}
526
554
else
527
555
{
528
556
assert (0 );
529
557
sys_error ("ERROR: unsupported type\n" );
530
558
}
531
559
560
+ if (listing && zipped )
561
+ {
562
+ sys_output ("%s\n" , root );
563
+ exit (0 );
564
+ }
565
+ else if (listing || zipped )
566
+ {
567
+ sys_error ("ERROR: Listing option without creating zip is useless\n" );
568
+ }
569
+
532
570
if (zipped )
533
571
{
534
572
sys_output ("[*] creating '%s' archive\n" , root );
0 commit comments