Changed interface of function mc_symlink()
[midnight-commander.git] / src / vfs / extfs / helpers / uc1541.in
blob842c1d1bf0d9369f55bbf1eb7fada5a502397ffc
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 which archiver you are using with appropriate options
16 C1541="c1541"
18 # There are no time stamps in the disk image, so a bogus timestamp is displayed
19 mc_c1541_fs_list()
21 if [ x"$UID" = x ]; then
22 UID=`id -ru 2>/dev/null`
23 if [ "x$UID" = "x" ]; then
24 UID=0
27 $C1541 "$1" -list | @AWK@ -v uid=$UID '
28 BEGIN { FS = "\"" }
29 /No LINES!/ { next }
30 /BLOCKS FREE/ { next }
31 $1 == 0 { next }
33 printf "-rw-r--r-- 1 %-8d %-8d %8d Jan 01 1980 00:00 %s\n", uid, 0, $1 * 256, $2
34 }' 2>/dev/null
37 # Command: copyout archivename storedfilename extractto
38 # -read image 1541name [fsname]
39 mc_c1541_fs_copyout()
41 $C1541 "$1" -read "$2" 2> /dev/null
42 mv "$2" "$3"
45 # FIXME mc can't do chown of the file inside the archive
46 # Command: copyin archivename storedfilename sourcefile
47 # -write image fsname [1541name]
48 mc_c1541_fs_copyin()
50 mv "$3" "$2"
51 $C1541 "$1" -write "$2" 2> /dev/null
54 # Command: rm archivename storedfilename
55 # -delete image files
56 mc_c1541_fs_rm()
58 $C1541 "$1" -delete "$2" 2> /dev/null
61 # The main routine
62 umask 077
64 cmd="$1"
65 shift
67 case "$cmd" in
68 list) mc_c1541_fs_list "$@" ;;
69 copyout) mc_c1541_fs_copyout "$@" ;;
70 # copyin) mc_c1541_fs_copyin "$@" ;;
71 rm) mc_c1541_fs_rm "$@" ;;
72 *) exit 1 ;;
73 esac
74 exit 0