Difference between revisions of "HOWTO-Extract Pegasus Prime/Script"

From ScummVM :: Wiki
Jump to navigation Jump to search
(Add back syntax highlighting)
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<source lang="bash">
<syntaxhighlight lang="bash">
#! /bin/sh -e
#! /bin/sh -e


Line 63: Line 63:
     humount $CDROM
     humount $CDROM
done
done
</source>
</syntaxhighlight>

Latest revision as of 15:16, 25 October 2018

#! /bin/sh -e

CDROM=/dev/cdrom
PREFIX=pegasus

copy_from_disc() {
    while read -r type srcfile
    do
	if [ -z "$type" -o "$type" = "#" ]
	then
	    continue
	fi

	drive=`echo $srcfile | cut -d ':' -f 1`

	if [ "$drive" != "$1" ]
	then
	    continue
	fi

	dstfile=$PREFIX/`echo $srcfile | cut -d ':' -f 3- | tr ':/' '/_'`

	case $type in
	    D)
		options=
		;;
	    M)
		options=-m
		dstfile=$dstfile.bin
		;;
	    R)
		options=-r
		;;
	esac

	if [ $type = "D" ]
	then
	    if [ ! -d "$dstfile" ]
	    then
		echo "Creating directory $dstfile"
		mkdir -p "$dstfile"
	    fi
	else
	    if [ ! -f "$dstfile" ]
	    then
		echo "Copying: $srcfile"
		hcopy $options "$srcfile" "$dstfile" 
	    else
		echo "Skipping file: $srcfile"
	    fi
	fi
    done < filelist.txt
}

mkdir -p "$PREFIX"

for disc in "PP Disk 1" "PP Disk 2" "PP Disk 3" "PP Disk 4"
do
    read -p "Insert CD '$disc', then press Enter..." nothing
    hmount $CDROM
    copy_from_disc "$disc"
    humount $CDROM
done