diff --git a/configure.ac b/configure.ac index dd96d6efd..4f542b567 100644 --- a/configure.ac +++ b/configure.ac @@ -625,6 +625,7 @@ src/vfs/extfs/helpers/ucab src/vfs/extfs/helpers/uha src/vfs/extfs/helpers/ulha src/vfs/extfs/helpers/ulib +src/vfs/extfs/helpers/unar src/vfs/extfs/helpers/urar src/vfs/extfs/helpers/uwim src/vfs/extfs/helpers/uzip diff --git a/misc/mc.ext.in b/misc/mc.ext.in index 4d4a3febb..bedfb7c70 100644 --- a/misc/mc.ext.in +++ b/misc/mc.ext.in @@ -176,6 +176,11 @@ type/^LHa\ .*archive Open=%cd %p/ulha:// View=%view{ascii} @EXTHELPERSDIR@/archive.sh view lha +# PAK +type/^PAK\ .*archive + Open=%cd %p/unar:// + View=%view{ascii} @EXTHELPERSDIR@/archive.sh view pak + # arj regex/i/\.a(rj|[0-9][0-9])$ Open=%cd %p/uarj:// diff --git a/src/vfs/extfs/helpers/.gitignore b/src/vfs/extfs/helpers/.gitignore index 14128aea5..44da1500c 100644 --- a/src/vfs/extfs/helpers/.gitignore +++ b/src/vfs/extfs/helpers/.gitignore @@ -20,6 +20,7 @@ uarj ucab uha ulha +unar urar uwim uzip diff --git a/src/vfs/extfs/helpers/Makefile.am b/src/vfs/extfs/helpers/Makefile.am index 87345114c..f1ea0acc3 100644 --- a/src/vfs/extfs/helpers/Makefile.am +++ b/src/vfs/extfs/helpers/Makefile.am @@ -31,6 +31,7 @@ EXTFS_IN = \ uha.in \ ulha.in \ ulib.in \ + unar.in \ urar.in \ uwim.in \ uzip.in \ @@ -61,6 +62,7 @@ EXTFS_OUT = \ uha \ ulha \ ulib \ + unar \ urar \ uwim \ uzip \ diff --git a/src/vfs/extfs/helpers/README.extfs b/src/vfs/extfs/helpers/README.extfs index 22ac8dfbb..ce7d0867c 100644 --- a/src/vfs/extfs/helpers/README.extfs +++ b/src/vfs/extfs/helpers/README.extfs @@ -73,3 +73,6 @@ patchsetfs - list of patches of current file # Gputils lib archives. ulib + +# PAK Archive +unar diff --git a/src/vfs/extfs/helpers/unar.in b/src/vfs/extfs/helpers/unar.in new file mode 100644 index 000000000..e81030733 --- /dev/null +++ b/src/vfs/extfs/helpers/unar.in @@ -0,0 +1,59 @@ +#! /bin/sh + +# Written by Ilia Maslakov +# +# (C) 2020 The Free Software Foundation. + +# Define awk +AWK=@AWK@ + +# Define which archiver you are using with appropriate options +UNAR_LIST="lsar " +UNAR_GET="unar " + +# The 'list' command executive +mc_unar_fs_list() +{ + # List the contents of the archive and sort it out + $UNAR_LIST -l "$1" | $AWK -v uid=`id -nu` -v gid=`id -ng` ' + BEGIN { flag = 0 } + /^\(Flags/ {next} + /^\(Mode/ {next} + { + flag++; + if (flag < 4) + next + pr="-r--r--r--" + if (index($2, "D") != 0) + pr="dr-xr-xr-x" + split($6, a, "-") + split($7, b, ":") + printf "%s 1 %s %s %d %02d/%02d/%02d %02d:%02d %s\n", pr, uid, gid, $3, a[3], a[2], a[1], b[1], b[2], $8 + }' +} + +# The 'copyout' command executive to copy displayed files to a destination +mc_unar_fs_copyout () +{ + TMPDIR=`mktemp -d "${MC_TMPDIR:-/tmp}/mctmpdir-uha.XXXXXX"` || exit 1 + + $UNAR_GET "$1" "$2" -o "$TMPDIR" >/dev/null + we=`basename "$1" | sed -E 's|^(.*?)\.\w+$|\1|'` + cat "$TMPDIR/$we/$2" > "$3" + cd / + rm -rf "$TMPDIR" +} + +# The main routine +umask 077 + +cmd="$1" +shift + +case "$cmd" in + list) mc_unar_fs_list "$@" ;; + copyout) mc_unar_fs_copyout "$@" ;; + *) exit 1 ;; +esac + +exit 0