#!/bin/csh -f
#
# floppy: insert a floppy into a drive
#
# usage: floppy s[56]d[12] <filename> <rights>
#
# where s6d1 means drive 1 of controller in slot 6
# filename is a anem of a apple disk image
# rights is one of r or rw (readonly and readwrite)
#
if ( -e $1 )  then
	if ( `file $1 | grep link | wc -l` == 0 ) then
		echo $1 is not a link.
		exit 1
	endif
endif

/bin/rm -f $1
/bin/ln -s $2 $1
if ( $3 == 'r' || $3 == 'rw' ) then
	/bin/chmod u=$3 $2
endif
if ( `echo $1 | grep s6d | wc -l` == 1 ) then
	kill -USR1 `cat .applepid`
else
	kill -USR2 `cat .applepid`
endif
