42 | | $UNRAR v -c- -cfg- "$1" | @AWK@ -v uid=`id -u` -v gid=`id -g` ' |
43 | | BEGIN { flag=0 } |
44 | | /^-----------/ { flag++; if (flag > 1) exit 0; next } |
45 | | flag==1 { |
46 | | split($5, a, "-") |
47 | | if (index($1, "D") != 0) |
48 | | $1="drwxr-xr-x" |
49 | | else |
50 | | if (index($1, ".") != 0) |
51 | | $1="-rw-r--r--" |
52 | | printf "%s 1 %s %s %d %02d/%02d/%02d %s ./%s\n", $1, uid, gid, $2, a[2], a[1], a[3], $6, $8 |
53 | | }' |
| 42 | $UNRAR vt "$1" | awk -F':' -v uid=`id -u` -v gid=`id -g` ' |
| 43 | { ### remove space after the ":" of the field-namer |
| 44 | sub("^ ", "", $2); |
| 45 | } |
| 46 | |
| 47 | $1 ~ / *Name$/ { ### next file |
| 48 | name = mtime = size = attrs = ""; delete date; |
| 49 | name = $2; |
| 50 | ### if the name contains ":", append the rest of the fields |
| 51 | if(NF > 2) { |
| 52 | for( i = 3; i <= NF; i++) { |
| 53 | name=name ":" $i; |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | $1 ~ /^ *mtime$/ { |
| 58 | mtime = $2 ":" $3; |
| 59 | } |
| 60 | $1 ~ /^ *Size$/ { |
| 61 | size = $2; |
| 62 | } |
| 63 | $1 ~ /^ *Attributes$/ { |
| 64 | attrs = $2; |
| 65 | } |
| 66 | |
| 67 | $1 ~ /^ *Compression$/ { ### file done, using /^$/ is not so good you |
| 68 | ### would have to skip the version stuff first |
| 69 | |
| 70 | ### get date and time |
| 71 | split(mtime, date, " "); |
| 72 | time = date[2]; |
| 73 | ### cut off seconds from the time |
| 74 | sub(",[0-9]*$", "", time); |
| 75 | ### split for reordering of the date in the printf below |
| 76 | split(date[1], date, "-"); |
| 77 | ### mc seems to be able to parse 4 digit years too, so remove if tested |
| 78 | # sub("^..", "", date[1]); ### c ut year to 2 digits only |
| 79 | |
| 80 | ### check/adjust rights |
| 81 | if (index(attrs, "D") != 0) { |
| 82 | attrs = "drwxr-xr-x"; |
| 83 | } else { |
| 84 | if (index(attrs, ".") != 0) { |
| 85 | attrs = "-rw-r--r--"; |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | ### and finally |
| 90 | printf("%s 1 %s %s %d %02d/%02d/%02d %s ./%s\n", |
| 91 | attrs, uid, gid, size, date[2], date[3], date[1], |
| 92 | time, name); |
| 93 | } |
| 94 | ' |