uc1541.in 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 your awk
  12. AWK=gawk
  13. # Define which archiver you are using with appropriate options
  14. C1541="c1541"
  15. # There are no time stamps in the disk image, so a bogus timestamp is displayed
  16. mc_c1541_fs_list()
  17. {
  18. $C1541 "$1" -list | gawk -v uid=${UID-0} '
  19. BEGIN { FS = "\"" }
  20. /No LINES!/ { next }
  21. /BLOCKS FREE/ { next }
  22. $1 == 0 { next }
  23. {
  24. printf "-rw-r--r-- 1 %-8d %-8d %8d Jan 01 1980 00:00 %s\n", uid, 0, $1 * 256, $2
  25. }' 2>/dev/null
  26. }
  27. # Command: copyout archivename storedfilename extractto
  28. # -read image 1541name [fsname]
  29. mc_c1541_fs_copyout()
  30. {
  31. $C1541 "$1" -read "$2" 2> /dev/null
  32. mv "$2" "$3"
  33. }
  34. # FIXME mc can't do chown of the file inside the archive
  35. # Command: copyin archivename storedfilename sourcefile
  36. # -write image fsname [1541name]
  37. mc_c1541_fs_copyin()
  38. {
  39. mv "$3" "$2"
  40. $C1541 "$1" -write "$2" 2> /dev/null
  41. }
  42. # Command: rm archivename storedfilename
  43. # -delete image files
  44. mc_c1541_fs_rm()
  45. {
  46. $C1541 "$1" -delete "$2" 2> /dev/null
  47. }
  48. # The main routine
  49. umask 077
  50. cmd="$1"
  51. shift
  52. case "$cmd" in
  53. list) mc_c1541_fs_list "$@" ;;
  54. copyout) mc_c1541_fs_copyout "$@" ;;
  55. # copyin) mc_c1541_fs_copyin "$@" ;;
  56. rm) mc_c1541_fs_rm "$@" ;;
  57. *) exit 1 ;;
  58. esac
  59. exit 0