From 7c7e6ab828badb1b5c427f348f9f4370e5e7d0ee Mon Sep 17 00:00:00 2001 From: Jeremy Rand Date: Mon, 18 Jun 2018 23:23:59 -0400 Subject: [PATCH] Implement the code to copy custom files to the disk image in the build --- Makefile | 21 ++++++++++++++++--- make/createDiskImage | 49 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 65 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 6e12e8b..7a8e4d0 100644 --- a/Makefile +++ b/Makefile @@ -208,9 +208,24 @@ SRCDIRS+= # # Then, during the copy phase, mySystemFile will be copied into the root # of the disk and anotherFile will be copied into a directory named -# newDir. Note that the build will _not_ create directories on your -# destination disk image. You must make sure that this directory -# exists in the template disk image in the make directory already. +# newDir. The newDir directory will be created if it does not already +# exist. +# +# The name of the file to copy is checked and if it ends in: +# .as - It assumes the file is in AppleSingle format. The .as +# suffix is stripped from the name when copied to the +# disk image. +# . - If the file ends with a single character which matches +# a DOS 3.3 file type (A, B, T, etc) it uses that value as +# the file type of the file copied to the disk image. The +# single character is removed from the file name. +# . - If the file ends with a three letter alpha extension, it +# uses that TLA as the file type of the file copied to the +# disk image. The TLA is removed from the file name. +# +# If you do not provide any type information for your filenames, +# it will be copied as a binary. +# COPYDIRS= # Add any rules you want to execute before any compiles or assembly diff --git a/make/createDiskImage b/make/createDiskImage index efae259..25e1c47 100755 --- a/make/createDiskImage +++ b/make/createDiskImage @@ -218,6 +218,51 @@ fi for DIR in $* do - echo Write the code to copy $DIR to the disk image - exit 1 + if [ ! -d "$DIR" ] + then + echo Unable to find directory $DIR + exit 1 + fi + + OLDPWD=`pwd` + cd $DIR + + find . -type f -print | while read FILE + do + TRANSFERARG=-p + FILETYPE=bin + DESTFILE=`echo $FILE | sed 's/^\.\///'` + + if echo $FILE | egrep '\.as$' > /dev/null + then + # If the file ends with .as, this means the input is AppleSingle format. + # Strip the .as from the end of the file name and set the args to do + # an AppleSingle transfer. + TRANSFERARG=-as + FILETYPE="" + DESTFILE=`echo $DESTFILE | sed 's/\.as$//'` + elif echo $FILE | egrep '\.[ABITSRab]$' > /dev/null + then + # If the file ends with a single character DOS 3.3 file type, then use + # that as the file type. + FILETYPE=`echo $DESTFILE | awk -F. '{print $NF}'` + DESTFILE=`echo $DESTFILE | sed 's/\.[ABITSRab]$//'` + elif echo $FILE | egrep '\.[a-zA-Z][a-zA-Z][a-zA-Z]$' > /dev/null + then + # If the file ends with a three letter extension, use that as + # the file type. + FILETYPE=`echo $DESTFILE | awk -F. '{print $NF}'` + DESTFILE=`echo $DESTFILE | sed 's/\.[a-zA-Z][a-zA-Z][a-zA-Z]$//'` + fi + + # If the file type is text, convert the line feeds to carriage return + if [ $FILETYPE = txt ] || [ $FILETYPE = T ] + then + tr '\n' '\r' < $FILE | "$JAVA" -jar "$OLDPWD/$APPLECOMMANDER" $TRANSFERARG "$OLDPWD/$DISKIMAGE" "$DESTFILE" $FILETYPE + else + "$JAVA" -jar "$OLDPWD/$APPLECOMMANDER" $TRANSFERARG "$OLDPWD/$DISKIMAGE" "$DESTFILE" $FILETYPE < $FILE + fi + done + + cd "$OLDPWD" done