mc/vfs/extfs/unarj.diff

127 lines
3.6 KiB
Diff
Raw Normal View History

2000-09-25 16:49:41 +04:00
diff -bur arj/unarj.c mc/unarj.c
--- arj/unarj.c Mon Sep 29 14:00:24 1997
+++ mc/unarj.c Fri Sep 22 21:44:29 2000
@@ -42,6 +42,7 @@
1998-10-13 02:07:53 +04:00
* 02/17/93 R. Jung Added archive modified date support.
2000-09-25 16:49:41 +04:00
* 01/22/94 R. Jung Changed copyright message.
* 07/29/96 R. Jung Added "/" to list of path separators.
1998-10-13 02:07:53 +04:00
+ * 02/16/98 pavel@ucw.cz Added v mode, added p mode. THIS IS MODIFIED VERSION.
*
*/
2000-09-25 16:49:41 +04:00
@@ -89,6 +90,7 @@
1998-10-13 02:07:53 +04:00
uchar header[HEADERSIZE_MAX];
char arc_name[FNAME_MAX];
int command;
+char *file_to_extract;
int bitcount;
int file_type;
int no_output;
2000-09-25 16:49:41 +04:00
@@ -103,6 +105,11 @@
1998-10-13 02:07:53 +04:00
" UNARJ l archive (list archive)\n",
" UNARJ t archive (test archive)\n",
" UNARJ x archive (extract with pathnames)\n",
2000-09-25 16:49:41 +04:00
+" UNARJ v archive (list archive with pathnames)\n",
1998-10-13 02:07:53 +04:00
+" UNARJ p archive file (print single file from archive to stderr)\n",
+"\n",
2000-09-25 16:49:41 +04:00
+"Warning, this version has been modified by pavel@ucw.cz\n",
+"to be used as virtual fs within mc (Midnight Commander).\n",
1998-10-13 02:07:53 +04:00
"\n",
"This is an ARJ demonstration program and ** IS NOT OPTIMIZED ** for speed.\n",
"You may freely use, copy and distribute this program, provided that no fee\n",
2000-09-25 16:49:41 +04:00
@@ -723,15 +730,24 @@
1998-10-13 02:07:53 +04:00
if (command == 'E')
strcpy(name, &filename[entry_pos]);
else
+ if (command == 'X')
2000-09-25 16:49:41 +04:00
{
strcpy(name, DEFAULT_DIR);
strcat(name, filename);
}
+ else
+ if (strcmp( &filename[0], file_to_extract ))
1998-10-13 02:07:53 +04:00
+ {
+ skip();
+ return 0;
+ }
+ else
+ strcpy( name, "stderr" );
if (host_os != OS)
default_case_path(name);
- if (file_exists(name))
+ if ((command != 'P') && file_exists(name))
{
printf(M_FEXISTS, name);
printf(M_SKIPPED, name);
2000-09-25 16:49:41 +04:00
@@ -739,7 +755,10 @@
error_count++;
return 0;
}
1998-10-13 02:07:53 +04:00
+ if (command != 'P')
2000-09-25 16:49:41 +04:00
outfile = file_open(name, writemode[file_type & 1]);
1998-10-13 02:07:53 +04:00
+ else
+ outfile = stderr;
if (outfile == NULL)
{
printf(M_CANTOPEN, name);
2000-09-25 16:49:41 +04:00
@@ -865,9 +884,12 @@
1998-10-13 02:07:53 +04:00
strcpy(fmode_str, " ");
if (host_os == OS)
get_mode_str(fmode_str, (uint) file_mode);
- if (strlen(&filename[entry_pos]) > 12)
+ if ((strlen(&filename[entry_pos]) > 12) || (command == 'V'))
+ if (command != 'V')
2000-09-25 16:49:41 +04:00
printf("%-12s\n ", &filename[entry_pos]);
1998-10-13 02:07:53 +04:00
else
2000-09-25 16:49:41 +04:00
+ printf("%s\n ", filename);
+ else
1998-10-13 02:07:53 +04:00
printf("%-12s ", &filename[entry_pos]);
printf("%10ld %10ld %u.%03u %s %08lX %4s%c%c%c%u%c%c%c\n",
2000-09-25 16:49:41 +04:00
origsize, compsize, r / 1000, r % 1000, &date_str[2], file_crc,
@@ -910,11 +932,13 @@
1998-10-13 02:07:53 +04:00
{
switch (command)
{
2000-09-25 16:49:41 +04:00
+ case 'P':
1998-10-13 02:07:53 +04:00
case 'E':
case 'X':
if (extract())
file_count++;
break;
2000-09-25 16:49:41 +04:00
+ case 'V':
1998-10-13 02:07:53 +04:00
case 'L':
list_arc(file_count++);
skip();
2000-09-25 16:49:41 +04:00
@@ -934,6 +958,7 @@
file_count, torigsize, tcompsize, r / 1000, r % 1000, &date_str[2]);
}
else
+ if (command != 'V')
printf(M_NBRFILES, file_count);
fclose(arcfile);
@@ -977,14 +1002,20 @@
1998-10-13 02:07:53 +04:00
if (strlen(argv[1]) > 1)
error(M_BADCOMND, argv[1]);
command = toupper(*argv[1]);
- if (strchr("ELTX", command) == NULL)
+ if (strchr("ELTXV", command) == NULL)
error(M_BADCOMND, argv[1]);
arc_p = argv[2];
}
else
{
+ command = toupper(*argv[1]);
+ if ((command!='P') || (argc != 4))
+ {
2000-09-25 16:49:41 +04:00
help();
return EXIT_FAILURE;
1998-10-13 02:07:53 +04:00
+ }
+ file_to_extract = argv[3];
+ arc_p = argv[2];
}
strncopy(arc_name, arc_p, FNAME_MAX);