uarc.in 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 which archiver you are using with appropriate options
  9. ARC_LIST="arc v"
  10. ARC_GET="arc x"
  11. ARC_PUT="arc a"
  12. ARC_DEL="arc d"
  13. # The 'list' command executive
  14. mc_arc_fs_list()
  15. {
  16. if [ "x$UID" = "x" ]; then
  17. UID=`id -ru 2>/dev/null`
  18. if [ "x$UID" = "x" ]; then
  19. UID=0
  20. fi
  21. fi
  22. $ARC_LIST "$1" | @AWK@ -v uid=$UID '
  23. BEGIN { }
  24. /^Name/ { next }
  25. /===/ { next }
  26. /^Total/ { next }
  27. {
  28. if ($8 > 50)
  29. $8=$8 + 1900
  30. else
  31. $8=$8 + 2000
  32. split($9, a, ":")
  33. # convert AM/PM to 00-23
  34. if (a[2] ~ /a$|p$/)
  35. {
  36. if (a[2] ~ /p$/)
  37. a[1] = a[1]+12
  38. a[2]=substr(a[2],1,2)
  39. }
  40. 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
  41. }' 2>/dev/null
  42. exit 0
  43. }
  44. # Command: copyout archivename storedfilename extractto
  45. mc_arc_fs_copyout()
  46. {
  47. $ARC_GET "$1" "$2" 2> /dev/null
  48. mv "$2" "$3"
  49. }
  50. # Command: copyin archivename storedfilename sourcefile
  51. mc_arc_fs_copyin()
  52. {
  53. mv "$3" "$2"
  54. $ARC_PUT "$1" "$2" 2> /dev/null
  55. }
  56. # Command: rm archivename storedfilename
  57. mc_arc_fs_rm()
  58. {
  59. $ARC_DEL "$1" "$2" 2> /dev/null
  60. }
  61. # The main routine
  62. umask 077
  63. cmd="$1"
  64. shift
  65. case "$cmd" in
  66. list) mc_arc_fs_list "$@" ;;
  67. copyout) mc_arc_fs_copyout "$@" ;;
  68. copyin) mc_arc_fs_copyin "$@" ;;
  69. rm) mc_arc_fs_rm "$@" ;;
  70. *) exit 1 ;;
  71. esac
  72. exit 0