#!/usr/bin/env bash

###
# This will create a new 1.44mb floppy disk image
###

DISKDIR="/home/gmgauthier/Retro/BLANKS"

# get name of freshly created blank disk, or create one
if [ $# -eq 0 ]; then
    echo ">>> NEW 1.44MB DISK IS BEING CREATED..."
    PREFIX="floppy"
    RANDO=$(od -An -N4 -i < /dev/urandom|sed 's/[ -]//g')
    DISK="$PREFIX$RANDO"
    dd if=/dev/zero of=$DISKDIR/$DISK.img bs=1k count=1440
else
    DISK=$1
    if [ $# -eq 1 ]; then
        echo "Second argument should be disk size in kbytes: 360, 720, 1440"
        exit 1
    fi
    SIZE=$2
    if ! [ -f $DISK.img ]; then
        dd if=/dev/zero of=$DISKDIR/$DISK.img bs=1k count=$SIZE
    fi
fi

