Merge branch '2121_dir_symlink'
[kaloumi3.git] / lib / vfs / mc-vfs / extfs / uc1541.in
blobfed3301f9bacad0ae9967fa970ffe2af675365ce
1 #! /bin/sh
4 # UC1541 Virtual filesystem executive v0.1
6 # This is for accessing disk image files for the Commodore VIC20/C64/C128
7 # It requires the utility c1541 that comes bundled with Vice, the emulator
8 # for the VIC20, C64, C128 and other computers made by Commodore.
10 # Copyright (C) 2008 Jacques Pelletier
11 # May be distributed under the terms of the GNU Public License
12 # <jpelletier@ieee.org>
15 # Define your awk
16 AWK=gawk
17 # Define which archiver you are using with appropriate options
18 C1541="c1541"
20 # There are no time stamps in the disk image, so a bogus timestamp is displayed
21 mc_c1541_fs_list()
23 $C1541 "$1" -list | gawk -v uid=${UID-0} '
24 BEGIN { FS = "\"" }
25 /No LINES!/ { next }
26 /BLOCKS FREE/ { next }
27 $1 == 0 { next }
29 printf "-rw-r--r-- 1 %-8d %-8d %8d Jan 01 1980 00:00 %s\n", uid, 0, $1 * 256, $2
30 }' 2>/dev/null
33 # Command: copyout archivename storedfilename extractto
34 # -read image 1541name [fsname]
35 mc_c1541_fs_copyout()
37 $C1541 "$1" -read "$2" 2> /dev/null
38 mv "$2" "$3"
41 # FIXME mc can't do chown of the file inside the archive
42 # Command: copyin archivename storedfilename sourcefile
43 # -write image fsname [1541name]
44 mc_c1541_fs_copyin()
46 mv "$3" "$2"
47 $C1541 "$1" -write "$2" 2> /dev/null
50 # Command: rm archivename storedfilename
51 # -delete image files
52 mc_c1541_fs_rm()
54 $C1541 "$1" -delete "$2" 2> /dev/null
57 # The main routine
58 umask 077
60 cmd="$1"
61 shift
63 case "$cmd" in
64 list) mc_c1541_fs_list "$@" ;;
65 copyout) mc_c1541_fs_copyout "$@" ;;
66 # copyin) mc_c1541_fs_copyin "$@" ;;
67 rm) mc_c1541_fs_rm "$@" ;;
68 *) exit 1 ;;
69 esac
70 exit 0