doc: switch links to https://, update or remove dead links
[midnight-commander.git] / src / vfs / extfs / helpers / unar.in
blobe81030733d4e36f11969636a86e0b050abf00d1d
1 #! /bin/sh
3 # Written by Ilia Maslakov <il.smind@gmail.com>
5 # (C) 2020 The Free Software Foundation.
7 # Define awk
8 AWK=@AWK@
10 # Define which archiver you are using with appropriate options
11 UNAR_LIST="lsar "
12 UNAR_GET="unar "
14 # The 'list' command executive
15 mc_unar_fs_list()
17 # List the contents of the archive and sort it out
18 $UNAR_LIST -l "$1" | $AWK -v uid=`id -nu` -v gid=`id -ng` '
19 BEGIN { flag = 0 }
20 /^\(Flags/ {next}
21 /^\(Mode/ {next}
23 flag++;
24 if (flag < 4)
25 next
26 pr="-r--r--r--"
27 if (index($2, "D") != 0)
28 pr="dr-xr-xr-x"
29 split($6, a, "-")
30 split($7, b, ":")
31 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
35 # The 'copyout' command executive to copy displayed files to a destination
36 mc_unar_fs_copyout ()
38 TMPDIR=`mktemp -d "${MC_TMPDIR:-/tmp}/mctmpdir-uha.XXXXXX"` || exit 1
40 $UNAR_GET "$1" "$2" -o "$TMPDIR" >/dev/null
41 we=`basename "$1" | sed -E 's|^(.*?)\.\w+$|\1|'`
42 cat "$TMPDIR/$we/$2" > "$3"
43 cd /
44 rm -rf "$TMPDIR"
47 # The main routine
48 umask 077
50 cmd="$1"
51 shift
53 case "$cmd" in
54 list) mc_unar_fs_list "$@" ;;
55 copyout) mc_unar_fs_copyout "$@" ;;
56 *) exit 1 ;;
57 esac
59 exit 0