uarc.in 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #! /bin/sh
  2. #
  3. # ARC Virtual filesystem executive
  4. # Copyright (C) 2008 Jacques Pelletier
  5. # May be distributed under the terms of the GNU Public License
  6. # <jpelletier@ieee.org>
  7. #
  8. # Define your awk
  9. AWK=gawk
  10. # Define which archiver you are using with appropriate options
  11. ARC_LIST="arc v"
  12. ARC_GET="arc x"
  13. ARC_PUT="arc a"
  14. ARC_DEL="arc d"
  15. # The 'list' command executive
  16. mc_arc_fs_list()
  17. {
  18. $ARC_LIST "$1" | gawk -v uid=${UID-0} '
  19. BEGIN { }
  20. /^Name/ { next }
  21. /===/ { next }
  22. /^Total/ { next }
  23. {
  24. if ($8 > 50)
  25. $8=$8 + 1900
  26. else
  27. $8=$8 + 2000
  28. split($9, a, ":")
  29. # convert AM/PM to 00-23
  30. if (a[2] ~ /a$|p$/)
  31. {
  32. if (a[2] ~ /p$/)
  33. a[1] = a[1]+12
  34. a[2]=substr(a[2],1,2)
  35. }
  36. printf "-rw-r--r-- 1 %-8d %-8d %8d %s %2d %4d %02d:%02d %s\n", uid, 0, $2, $7, $6, $8, a[1], a[2], $1
  37. }' 2>/dev/null
  38. exit 0
  39. }
  40. # Command: copyout archivename storedfilename extractto
  41. mc_arc_fs_copyout()
  42. {
  43. $ARC_GET "$1" "$2" 2> /dev/null
  44. mv "$2" "$3"
  45. }
  46. # Command: copyin archivename storedfilename sourcefile
  47. mc_arc_fs_copyin()
  48. {
  49. mv "$3" "$2"
  50. $ARC_PUT "$1" "$2" 2> /dev/null
  51. }
  52. # Command: rm archivename storedfilename
  53. mc_arc_fs_rm()
  54. {
  55. $ARC_DEL "$1" "$2" 2> /dev/null
  56. }
  57. # The main routine
  58. umask 077
  59. cmd="$1"
  60. shift
  61. case "$cmd" in
  62. list) mc_arc_fs_list "$@" ;;
  63. copyout) mc_arc_fs_copyout "$@" ;;
  64. copyin) mc_arc_fs_copyin "$@" ;;
  65. rm) mc_arc_fs_rm "$@" ;;
  66. *) exit 1 ;;
  67. esac
  68. exit 0