3 # Written by andrey joukov
4 # (C) 1996 2:5020/337.13@fidonet.org
5 # Updated by christian.gennerat@alcatel.fr 1999
6 # Andrew V. Samoilov <sav@bcs.zp.ua> 2000
8 # Andrew Borodin <aborodin@vmail.ru>
9 # David Haller <dnh@opensuse.org>
10 # 2013: support unrar5
14 # rar and unrar can be found on http://www.rarlabs.com/
18 # Prefer unrar (freeware).
19 UNRAR
=`command -v unrar 2>/dev/null`
21 [ -z $UNRAR ] && UNRAR
=$RAR
22 [ ! -x $UNRAR -a -x $RAR ] && UNRAR
=$RAR
24 # Let the test framework hook in:
25 UNRAR
=${MC_TEST_EXTFS_LIST_CMD:-$UNRAR}
27 # Determine the $UNRAR version
28 if [ -n "$MC_TEST_EXTFS_UNRAR_VERSION" ]; then
29 # Let the test framework fool us:
30 UNRAR_VERSION
=$MC_TEST_EXTFS_UNRAR_VERSION
32 # Figure it out from rar itself:
33 UNRAR_VERSION
=`$UNRAR -cfg- -? | grep "Copyright" | sed -e 's/.*\([0-9]\)\..*/\1/'`
38 $UNRAR v
-c- -cfg- "$1" | @AWK@
-v uid
=`id -u` -v gid
=`id -g` '
40 /^-------/ { flag++; if (flag > 1) exit 0; next }
45 if (index($6, "D") != 0)
48 if (index($6, ".") != 0)
50 printf "%s 1 %s %s %d %02d/%02d/%02d %s ./%s\n", $6, uid, gid, $1, a[2], a[1], a[3], $5, str
56 $UNRAR vt
-c- -cfg- "$1" | @AWK@
-F ':' -v uid
=`id -u` -v gid
=`id -g` '
58 ### remove space after the ":" of the field name
64 name = mtime = size = attrs = "";
67 ### if the name contains ":", append the rest of the fields
69 for (i = 3; i <= NF; i++) {
80 $1 ~ /^ *Attributes$/ {
84 $1 ~ /^ *Compression$/ {
85 ### file done, using /^$/ is not so good you
86 ### would have to skip the version stuff first
89 split (mtime, date, " ");
91 ### cut off seconds from the time
92 sub (",[0-9]*$", "", time);
93 ### split for reordering of the date in the printf below
94 split (date[1], date, "-");
95 ### mc seems to be able to parse 4 digit years too, so remove if tested
96 # sub ("^..", "", date[1]); ### cut year to 2 digits only
98 ### check/adjust rights
99 if (index (attrs, "D") != 0) {
100 attrs = "drwxr-xr-x";
102 if (index (attrs, ".") != 0) {
103 attrs = "-rw-r--r--";
108 printf ("%s 1 %s %s %d %02d/%02d/%02d %s ./%s\n",
109 attrs, uid, gid, size, date[2], date[3], date[1], time, name);
116 case x
$UNRAR_VERSION in
117 x5 | x6 | x7
) mcrar5fs_list
"$@" ;;
118 *) mcrar4fs_list
"$@" ;;
124 # copyin by christian.gennerat@alcatel.fr
125 # preserve pwd. It is clean, but is it necessary?
127 # Create a directory and copy in it the tmp file with the good name
131 # if file is to be written upper in the archive tree, make fake dir
132 if test x
"$di" != x
"${2##*/}" ; then
135 cp -fp "$3" "$3.dir/$2"
136 $RAR a
"$1" "$2" >/dev
/null
143 $UNRAR p
-p- -c- -cfg- -inul "$1" "$2" > "$3"
148 # preserve pwd. It is clean, but is it necessary?
150 # Create a directory and create in it a tmp directory with the good name
151 dir
=`mktemp -d "${MC_TMPDIR:-/tmp}/mctmpdir-urar.XXXXXX"` ||
exit 1
154 # rar cannot create an empty directory
156 $RAR a
-r "$1" "$2" >/dev
/null
157 $RAR d
"$1" "$2/.rarfs" >/dev
/null
164 $RAR d
"$1" "$2" >/dev
/null
173 # Workaround for a bug in mc - directories must precede files to
174 # avoid duplicate entries, so we sort output by filenames
175 list
) mcrarfs_list
"$@" |
sort -k 8 ;;
176 rm) mcrarfs_rm
"$@" ;;
177 rmdir) mcrarfs_rm
"$@" ;;
178 mkdir
) mcrarfs_mkdir
"$@" ;;
179 copyin
) mcrarfs_copyin
"$@" ;;
180 copyout
) mcrarfs_copyout
"$@" ;;