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
=`which unrar 2>/dev/null`
21 [ -z $UNRAR ] && UNRAR
=$RAR
22 [ ! -x $UNRAR -a -x $RAR ] && UNRAR
=$RAR
24 # Define $UNRAR version
25 UNRAR_VERSION
=`$UNRAR -? | grep "Copyright" | sed -e 's/.*\([0-9]\)\..*/\1/'`
29 $UNRAR v
-c- -cfg- "$1" | @AWK@
-v uid
=`id -u` -v gid
=`id -g` '
31 /^-------/ { flag++; if (flag > 1) exit 0; next }
36 if (index($6, "D") != 0)
39 if (index($6, ".") != 0)
41 printf "%s 1 %s %s %d %02d/%02d/%02d %s ./%s\n", $6, uid, gid, $1, a[2], a[1], a[3], $5, str
47 $UNRAR vt
-c- -cfg- "$1" | @AWK@
-F ':' -v uid
=`id -u` -v gid
=`id -g` '
49 ### remove space after the ":" of the field name
55 name = mtime = size = attrs = "";
58 ### if the name contains ":", append the rest of the fields
60 for (i = 3; i <= NF; i++) {
71 $1 ~ /^ *Attributes$/ {
75 $1 ~ /^ *Compression$/ {
76 ### file done, using /^$/ is not so good you
77 ### would have to skip the version stuff first
80 split (mtime, date, " ");
82 ### cut off seconds from the time
83 sub (",[0-9]*$", "", time);
84 ### split for reordering of the date in the printf below
85 split (date[1], date, "-");
86 ### mc seems to be able to parse 4 digit years too, so remove if tested
87 # sub ("^..", "", date[1]); ### cut year to 2 digits only
89 ### check/adjust rights
90 if (index (attrs, "D") != 0) {
93 if (index (attrs, ".") != 0) {
99 printf ("%s 1 %s %s %d %02d/%02d/%02d %s ./%s\n",
100 attrs, uid, gid, size, date[2], date[3], date[1], time, name);
107 [ x
$UNRAR_VERSION = x5
] && mcrar5fs_list
"$@" || mcrar4fs_list
"$@"
112 # copyin by christian.gennerat@alcatel.fr
113 # preserve pwd. It is clean, but is it necessary?
115 # Create a directory and copy in it the tmp file with the good name
119 # if file is to be written upper in the archive tree, make fake dir
120 if test x
"$di" != x
"${2##*/}" ; then
123 cp -fp "$3" "$3.dir/$2"
124 $RAR a
"$1" "$2" >/dev
/null
131 $UNRAR p
-p- -c- -cfg- -inul "$1" "$2" > "$3"
136 # preserve pwd. It is clean, but is it necessary?
138 # Create a directory and create in it a tmp directory with the good name
139 dir
=`mktemp -d "${MC_TMPDIR:-/tmp}/mctmpdir-urar.XXXXXX"` ||
exit 1
142 # rar cannot create an empty directory
144 $RAR a
-r "$1" "$2" >/dev
/null
145 $RAR d
"$1" "$2/.rarfs" >/dev
/null
152 $RAR d
"$1" "$2" >/dev
/null
161 # Workaround for a bug in mc - directories must precede files to
162 # avoid duplicate entries, so we sort output by filenames
163 list
) mcrarfs_list
"$@" |
sort -k 8 ;;
164 rm) mcrarfs_rm
"$@" ;;
165 rmdir) mcrarfs_rm
"$@" ;;
166 mkdir
) mcrarfs_mkdir
"$@" ;;
167 copyin
) mcrarfs_copyin
"$@" ;;
168 copyout
) mcrarfs_copyout
"$@" ;;