uarj.in 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #! /bin/sh
  2. #
  3. # Written by Viatcheslav Odintsov (2:5020/181)
  4. # (C) 2002 ARJ Software Russia.
  5. #
  6. # This is an updated parser for ARJ archives in Midnight Commander. You need
  7. # full ARJ rather than UNARJ. Open-source ARJ v 3.10 for Unix platforms can
  8. # be obtained here:
  9. #
  10. # - http://www.sourceforge.net/projects/arj/
  11. # - http://arj.sourceforge.net/
  12. ARJ="arj -+ -ja1"
  13. mcarjfs_list ()
  14. {
  15. $ARJ v "$1" | @AWK@ -v uuid=$(id -ru) '
  16. {
  17. if (($0 ~ /^[0-9]+\) .*/)||($0 ~ /^------------ ---------- ---------- -----/)){
  18. if (filestr ~ /^[0-9]+\) .*/) {
  19. printf "%s 1 %-8d %-8d %8d %02d-%02d-%02d %02d:%02d %s%s\n", perm, uid, gid, size, date[2], date[3], date[1], time[1], time[2], file, symfile
  20. perm=""
  21. file=""
  22. symfile=""
  23. filestr=""
  24. }
  25. }
  26. if ($0 ~ /^[0-9]+\) .*/) {
  27. filestr=$0
  28. sub(/^[0-9]*\) /, "")
  29. file=$0
  30. uid=uuid
  31. gid=0
  32. }
  33. if ($0 ~ /^.* [0-9]+[\t ]+[0-9]+ [0-9]\.[0-9][0-9][0-9] [0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].*/) {
  34. size=$3
  35. split($6, date, "-")
  36. split($7, time, ":")
  37. if ($8 ~ /^[rwx-]/) {perm=$8;}
  38. else {perm="-rw-r--r--"}
  39. }
  40. if ($0 ~ /^[\t ]+SymLink -> .*/) {
  41. symfile = " -> "$3
  42. perm="l"substr(perm, 2)
  43. }
  44. if ($0 ~ /^[\t ]+Owner: UID [0-9]+\, GID [0-9]+/) {
  45. uid=$3
  46. gid=$5
  47. owner=1
  48. }
  49. }'
  50. }
  51. mcarjfs_copyout ()
  52. {
  53. $ARJ e -y "$1" "$2" -jw"$3" >/dev/null 2>/dev/null
  54. }
  55. umask 077
  56. cmd="$1"
  57. shift
  58. case "$cmd" in
  59. list) mcarjfs_list "$@" ;;
  60. copyout) mcarjfs_copyout "$@" ;;
  61. *) exit 1 ;;
  62. esac
  63. exit 0