uar.in 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/bin/sh
  2. #
  3. # Written by Alex Kuchma <ask@bcs.zp.ua>
  4. # Alex Tkachenko <alex@bcs.zp.ua>
  5. # Updated by Vitezslav Samel <xsamel00@dcse.fee.vutbr.cz>
  6. #
  7. # (C) 1997, 1998 The Free Software Foundation.
  8. #
  9. #
  10. XAR=ar
  11. mcarfs_list ()
  12. {
  13. # If $temp_replace string is part of the filename that part might get lost
  14. temp_replace='Unique Separator String'
  15. thisyear="`date +%Y`"
  16. $XAR tv "$1" | sed 's,^,-,;s, , 1 ,;s,/, ,' |
  17. sed -e "s/\( [0-2][0-9]\:[0-5][0-9]\)\( $thisyear \)\(.*\)/\1$temp_replace\3/" |
  18. sed -e "s/\( [0-2][0-9]\:[0-5][0-9] \)\([12][0-9][0-9][0-9] \)\(.*\)/ \2\3/" |
  19. sed -e "s/$temp_replace/ /"
  20. }
  21. mcarfs_copyout ()
  22. {
  23. $XAR p "$1" "$2" > "$3"
  24. }
  25. mcarfs_copyin ()
  26. {
  27. TMPDIR=`mktemp -d "${MC_TMPDIR:-/tmp}/mctmpdir-uar.XXXXXX"` || exit 1
  28. name=`basename "$2"`
  29. (cd "$TMPDIR" && cp -fp "$3" "$name" && $XAR r "$1" "$name")
  30. rm -rf "$TMPDIR"
  31. }
  32. mcarfs_rm ()
  33. {
  34. $XAR d "$1" "$2"
  35. }
  36. # override any locale for dates
  37. LC_ALL=C
  38. export LC_ALL
  39. umask 077
  40. case "$1" in
  41. list) mcarfs_list "$2" ;;
  42. copyout) shift; mcarfs_copyout "$@" ;;
  43. copyin) shift; mcarfs_copyin "$@" ;;
  44. rm) shift; mcarfs_rm "$@" ;;
  45. mkdir|rmdir)
  46. echo "mcarfs: ar archives cannot contain directories." 1>&2
  47. exit 1;;
  48. *)
  49. echo "mcarfs: unknown command: \"$1\"." 1>&2
  50. exit 1;;
  51. esac
  52. exit 0