#!/bin/sh
#############################################
# mkfloppy: fraziona un grosso file in floppy 
# by M. Andreoli (1997)
# personal use only
############################################

#set -x

# Syntax 

USAGE="Split a big file in 1.44M files\n\
USAGE: `basename $0` [-h] [-copy|-c] [file]"

case "Z$1Z" in
ZZ|Z-hZ)
	echo -e $USAGE
	exit 0
	;;
Z-copyZ|Z-cZ)  copy=yes ; shift
esac


#Main 

label=disk
bigfile=$1

blocksize=1474560
f=0

while [ 1 ]
do

dd if=${bigfile} of=${label}.${f} bs=${blocksize} skip=${f} count=1 2> /dev/null

if file ${label}.${f} | grep 'empty' > /dev/null
then
	rm ${label}.${f}
	exit 0
fi

echo  "Disk N. ${f}"

if [ ${copy} ]
then
read -p "	Insert floppy and press -ENTER- " x

read -p "	Format (y/N)? " format

[ "${format}" = y ] && fdformat /dev/fd0H1440

echo -n "	Copying ..."
cat ${label}.${f} > /dev/fd0H1440
echo   ' Done!.'
fi

f=`expr $f + 1`

done

echo
echo "Rebuild $bigfile with"
echo " cat ${label}.\* > $bigfile"


#End

