uc1541.in 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #! /bin/sh
  2. #
  3. # UC1541 Virtual filesystem executive v0.1
  4. # This is for accessing disk image files for the Commodore VIC20/C64/C128
  5. # It requires the utility c1541 that comes bundled with Vice, the emulator
  6. # for the VIC20, C64, C128 and other computers made by Commodore.
  7. # Copyright (C) 2008 Jacques Pelletier
  8. # May be distributed under the terms of the GNU Public License
  9. # <jpelletier@ieee.org>
  10. #
  11. # Define which archiver you are using with appropriate options
  12. C1541="c1541"
  13. # There are no time stamps in the disk image, so a bogus timestamp is displayed
  14. mc_c1541_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. $C1541 "$1" -list | @AWK@ -v uid=$UID '
  23. BEGIN { FS = "\"" }
  24. /No LINES!/ { next }
  25. /BLOCKS FREE/ { next }
  26. $1 == 0 { next }
  27. {
  28. printf "-rw-r--r-- 1 %-8d %-8d %8d Jan 01 1980 00:00 %s\n", uid, 0, $1 * 256, $2
  29. }' 2>/dev/null
  30. }
  31. # Command: copyout archivename storedfilename extractto
  32. # -read image 1541name [fsname]
  33. mc_c1541_fs_copyout()
  34. {
  35. $C1541 "$1" -read "$2" 2> /dev/null
  36. mv "$2" "$3"
  37. }
  38. # FIXME mc can't do chown of the file inside the archive
  39. # Command: copyin archivename storedfilename sourcefile
  40. # -write image fsname [1541name]
  41. mc_c1541_fs_copyin()
  42. {
  43. mv "$3" "$2"
  44. $C1541 "$1" -write "$2" 2> /dev/null
  45. }
  46. # Command: rm archivename storedfilename
  47. # -delete image files
  48. mc_c1541_fs_rm()
  49. {
  50. $C1541 "$1" -delete "$2" 2> /dev/null
  51. }
  52. # The main routine
  53. umask 077
  54. cmd="$1"
  55. shift
  56. case "$cmd" in
  57. list) mc_c1541_fs_list "$@" ;;
  58. copyout) mc_c1541_fs_copyout "$@" ;;
  59. # copyin) mc_c1541_fs_copyin "$@" ;;
  60. rm) mc_c1541_fs_rm "$@" ;;
  61. *) exit 1 ;;
  62. esac
  63. exit 0