auto-detect AppleDouble file or Nulib2 extended filename; remove -ad and -f

This commit is contained in:
Ivan X 2016-02-02 00:41:01 -05:00
parent e3a0bd40d4
commit c61f6ebb3b

View File

@ -20,12 +20,11 @@ helpExit () {
echoerr " into ProDOS disk image. <type> is either three-letter or numeric" echoerr " into ProDOS disk image. <type> is either three-letter or numeric"
echoerr " ProDOS file type (BIN if omitted). Will read from stdin if supplied." echoerr " ProDOS file type (BIN if omitted). Will read from stdin if supplied."
echoerr " ProDOS subdirectories in <filename> will be created if needed." echoerr " ProDOS subdirectories in <filename> will be created if needed."
echoerr " If an AppleDouble file or Nulib2 extended filename is detected,"
echoerr " <type> and <auxtype> are automatically set, and resource forks are kept."
echoerr " (To extract these from a ProDOS image file, use cppo -ad or cppo -e.)"
echoerr "-c <filename> <imagename> [[$|0x]<type>] [[$|0x]<auxtype>] synonym for -p" echoerr "-c <filename> <imagename> [[$|0x]<type>] [[$|0x]<auxtype>] synonym for -p"
echoerr " with filename and imagename reversed." echoerr " with filename and imagename reversed."
echoerr "-ad <imagename> <filename>"
echoerr " copy AppleDouble file into ProDOS disk image"
echoerr "-f <imagename> <filename>"
echoerr " copy Nulib2 extended filename into ProDOS disk image"
#echoerr "-cd <imagename> <filename> <dateTimeString>|<dateTimeStamp>" #echoerr "-cd <imagename> <filename> <dateTimeString>|<dateTimeStamp>"
#echoerr " set creation date and time of file in ProDOS disk image" #echoerr " set creation date and time of file in ProDOS disk image"
#echoerr "-md <imagename> <filename> <dateTimeString>|<dateTimeStamp>" #echoerr "-md <imagename> <filename> <dateTimeString>|<dateTimeStamp>"
@ -167,7 +166,7 @@ if [[ $arg1 != "-i" && $arg1 != "-ls" && $arg1 != "-l" && $arg1 != "-ll" && $arg
vsd2_md5="$(md5sum /usr/local/adtpro/disks/Virtual2.po)" vsd2_md5="$(md5sum /usr/local/adtpro/disks/Virtual2.po)"
fi fi
if [[ ( $arg1 == "-p" || $arg1 == "-c" || $arg1 == "-g" || $arg1 == "-e" || $arg1 == "-ad" || $arg1 == "-f" ) && $2 && $3 ]]; then if [[ ( $arg1 == "-p" || $arg1 == "-c" || $arg1 == "-g" || $arg1 == "-e" ) && $2 && $3 ]]; then
AD= AD=
EX= EX=
@ -175,24 +174,23 @@ if [[ ( $arg1 == "-p" || $arg1 == "-c" || $arg1 == "-g" || $arg1 == "-e" || $arg
prodosArgParent= prodosArgParent=
rFile= rFile=
getArg= getArg=
if [[ $arg1 == "-p" ]]; then if [[ $arg1 == "-c" || $arg1 == "-p" ]]; then
prodosArg="$3" if [[ $arg1 == "-c" ]]; then
imageArg="$2" prodosArg="$2"
elif [[ $arg1 == "-ad" || $arg1 == "-f" ]]; then imageArg="$3"
prodosArg="$3" elif [[ $arg1 == "-p" ]]; then
imageArg="$2" prodosArg="$3"
imageArg="$2"
fi
[[ $prodosArg == *"/"* ]] && prodosArgParent="${prodosArg%/*}/" [[ $prodosArg == *"/"* ]] && prodosArgParent="${prodosArg%/*}/"
if [[ $arg1 == "-ad" ]]; then rFile="${prodosArgParent}.AppleDouble/${prodosArg##*/}"
if [[ -f "$prodosArg" && -f "$rFile" ]]; then # AppleDouble
AD=1 AD=1
rFile="${prodosArgParent}.AppleDouble/${prodosArg##*/}" elif [ -f "${prodosArg%#*}"#?????? ]; then # Nulib2 ext filename
else
EX=1 EX=1
prodosArg=$(echo -n "${prodosArg%#*}"#??????) prodosArg=$(echo -n "${prodosArg%#*}"#??????)
rFile="${prodosArg}"r rFile="${prodosArg}"r
fi fi
elif [[ $arg1 == "-c" ]]; then
prodosArg="$2"
imageArg="$3"
elif [[ $arg1 == "-g" || $arg1 == "-e" ]]; then elif [[ $arg1 == "-g" || $arg1 == "-e" ]]; then
fileArg="$3" fileArg="$3"
imageArg="$2" imageArg="$2"
@ -204,10 +202,12 @@ if [[ ( $arg1 == "-p" || $arg1 == "-c" || $arg1 == "-g" || $arg1 == "-e" || $arg
shift shift
if [[ $getArg ]]; then # get file if [[ $getArg ]]; then # get file
outFile= outFile=
[[ $3 && $3 != "-" ]] && outFile="$3" [[ $3 && $3 != "-" ]] && outFile="$3"
[[ ! $3 ]] && outFile="${2##*/}" [[ ! $3 ]] && outFile="${2##*/}"
java -Xmx128m -jar "$acPath" $getArg "$imageArg" "$fileArg" $outFile 2> $acmdStdErr java -Xmx128m -jar "$acPath" $getArg "$imageArg" "$fileArg" $outFile 2> $acmdStdErr
else # put file else # put file
# test ProDOS name validity # test ProDOS name validity