mirror of
https://github.com/RasppleII/a2cloud.git
synced 2025-01-07 07:29:22 +00:00
support nulib2 extended filenames for metadata and extended files
bit conversion bug fix
This commit is contained in:
parent
109462c5a6
commit
e3a0bd40d4
108
setup/acmd.txt
108
setup/acmd.txt
@ -4,19 +4,6 @@
|
|||||||
# set default AppleCommander location if ADTPro is not installed
|
# set default AppleCommander location if ADTPro is not installed
|
||||||
defaultAcPath=$(echo -n /usr/local/bin/AppleCommander-*-ac.jar)
|
defaultAcPath=$(echo -n /usr/local/bin/AppleCommander-*-ac.jar)
|
||||||
|
|
||||||
decToHex () {
|
|
||||||
# converts single-byte decimal value to hexadecimal equivalent
|
|
||||||
# arg: decimal value from 0-255
|
|
||||||
# out: two-digit hex value from 00-FF
|
|
||||||
#exit: 8=extraneous arg, 11=missing arg, 21=invalid arg
|
|
||||||
[[ $arg1 ]] || return 11
|
|
||||||
[[ $2 ]] && return 8
|
|
||||||
[[ ( $(printf %d "$arg1" 2> /dev/null) == $arg1 ) \
|
|
||||||
&& ( $arg1 -ge 0 ) && ( $arg1 -le 255 ) ]] || return 21
|
|
||||||
# args are valid
|
|
||||||
printf %02X "$arg1"
|
|
||||||
}
|
|
||||||
|
|
||||||
echoerr() {
|
echoerr() {
|
||||||
echo "$@" 1>&2;
|
echo "$@" 1>&2;
|
||||||
}
|
}
|
||||||
@ -37,6 +24,8 @@ helpExit () {
|
|||||||
echoerr " with filename and imagename reversed."
|
echoerr " with filename and imagename reversed."
|
||||||
echoerr "-ad <imagename> <filename>"
|
echoerr "-ad <imagename> <filename>"
|
||||||
echoerr " copy AppleDouble file into ProDOS disk image"
|
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>"
|
||||||
@ -63,12 +52,12 @@ helpExit () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
decToBin () {
|
decToBin () {
|
||||||
dec=$1
|
dec="$(( 10#$1 ))"
|
||||||
bits=""
|
bits=""
|
||||||
for i in 7 6 5 4 3 2 1 0; do
|
for i in 7 6 5 4 3 2 1 0; do
|
||||||
bits+=$(( (dec & (2**i)) >> i ))
|
bits+=$(( (dec & (2**i)) >> i ))
|
||||||
done
|
done
|
||||||
echo "1${bits#*1}"
|
echo -n "$(( 10#$bits ))"
|
||||||
}
|
}
|
||||||
|
|
||||||
arg1=$1
|
arg1=$1
|
||||||
@ -178,18 +167,29 @@ 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" ) && $2 && $3 ]]; then
|
if [[ ( $arg1 == "-p" || $arg1 == "-c" || $arg1 == "-g" || $arg1 == "-e" || $arg1 == "-ad" || $arg1 == "-f" ) && $2 && $3 ]]; then
|
||||||
|
|
||||||
adFile=
|
AD=
|
||||||
|
EX=
|
||||||
|
prodosArg=
|
||||||
|
prodosArgParent=
|
||||||
|
rFile=
|
||||||
getArg=
|
getArg=
|
||||||
if [[ $arg1 == "-p" ]]; then
|
if [[ $arg1 == "-p" ]]; then
|
||||||
prodosArg="$3"
|
prodosArg="$3"
|
||||||
imageArg="$2"
|
imageArg="$2"
|
||||||
elif [[ $arg1 == "-ad" ]]; then
|
elif [[ $arg1 == "-ad" || $arg1 == "-f" ]]; then
|
||||||
prodosArg="$3"
|
prodosArg="$3"
|
||||||
imageArg="$2"
|
imageArg="$2"
|
||||||
[[ $prodosArg == *"/"* ]] && adFile="${prodosArg%/*}/"
|
[[ $prodosArg == *"/"* ]] && prodosArgParent="${prodosArg%/*}/"
|
||||||
adFile+=".AppleDouble/${prodosArg##*/}"
|
if [[ $arg1 == "-ad" ]]; then
|
||||||
|
AD=1
|
||||||
|
rFile="${prodosArgParent}.AppleDouble/${prodosArg##*/}"
|
||||||
|
else
|
||||||
|
EX=1
|
||||||
|
prodosArg=$(echo -n "${prodosArg%#*}"#??????)
|
||||||
|
rFile="${prodosArg}"r
|
||||||
|
fi
|
||||||
elif [[ $arg1 == "-c" ]]; then
|
elif [[ $arg1 == "-c" ]]; then
|
||||||
prodosArg="$2"
|
prodosArg="$2"
|
||||||
imageArg="$3"
|
imageArg="$3"
|
||||||
@ -210,8 +210,8 @@ if [[ ( $arg1 == "-p" || $arg1 == "-c" || $arg1 == "-g" || $arg1 == "-e" || $arg
|
|||||||
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 legitimacy
|
# test ProDOS name validity
|
||||||
prodosPath=$(tr [:lower:] [:upper:] <<< $prodosArg )
|
prodosPath=$(tr [:lower:] [:upper:] <<< "${prodosArg%#*}" )
|
||||||
IFS_orig="$IFS"; IFS="/";
|
IFS_orig="$IFS"; IFS="/";
|
||||||
prodosPathParts="$prodosPath"
|
prodosPathParts="$prodosPath"
|
||||||
for thisProdosPathPart in $prodosPathParts; do
|
for thisProdosPathPart in $prodosPathParts; do
|
||||||
@ -225,7 +225,7 @@ if [[ ( $arg1 == "-p" || $arg1 == "-c" || $arg1 == "-g" || $arg1 == "-e" || $arg
|
|||||||
P_00=UNK; P_01=BAD; P_02=PCD; P_03=PTX; P_04=TXT; P_05=PDA; P_06=BIN; P_07=FNT; P_08=FOT; P_09=BA3; P_0a=DA3; P_0b=WPF; P_0c=SOS; P_0f=DIR; P_10=RPD; P_11=RPI; P_12=AFD; P_13=AFM; P_14=AFR; P_15=SCL; P_16=PFS; P_19=ADB; P_1a=AWP; P_1b=ASP; P_20=TDM; P_21=IPS; P_22=UPV; P_29=3SD; P_2a=8SC; P_2b=8OB; P_2c=8IC; P_2d=8LD; P_2e=P8C; P_41=OCR; P_42=FTD; P_50=GWP; P_51=GSS; P_52=GDB; P_53=DRW; P_54=GDP; P_55=HMD; P_56=EDU; P_57=STN; P_58=HLP; P_59=COM; P_5a=CFG; P_5b=ANM; P_5c=MUM; P_5d=ENT; P_5e=DVU; P_60=PRE; P_6b=BIO; P_6d=DVR; P_6e=PRE; P_6f=HDV; P_80=GEZ; P_81=GE1; P_82=GEO; P_83=GE3; P_84=GE4; P_85=GE5; P_86=GE6; P_87=GE7; P_88=GE8; P_89=GE9; P_8a=GEA; P_8b=GEB; P_8c=GEC; P_8d=GED; P_8e=GEE; P_8f=GEF; P_a0=WP_; P_ab=GSB; P_ac=TDF; P_ad=BDF; P_b0=SRC; P_b1=OBJ; P_b2=LIB; P_b3=S16; P_b4=RTL; P_b5=EXE; P_b6=STR; P_b7=TSF; P_b8=NDA; P_b9=CDA; P_ba=TOL; P_bb=DRV; P_bc=LDF; P_bd=FST; P_bf=DOC; P_c0=PNT; P_c1=PIC; P_c2=ANI; P_c3=PAL; P_c5=OOG; P_c6=SCR; P_c7=CDV; P_c8=FON; P_c9=FND; P_ca=ICN; P_d5=MUS; P_d6=INS; P_d7=MDI; P_d8=SND; P_db=DBM; P_e0=SHK; P_e2=DTS; P_ee=R16; P_ef=PAS; P_f0=CMD; P_f9=P16; P_fa=INT; P_fb=IVR; P_fc=BAS; P_fd=VAR; P_fe=REL; P_ff=SYS;
|
P_00=UNK; P_01=BAD; P_02=PCD; P_03=PTX; P_04=TXT; P_05=PDA; P_06=BIN; P_07=FNT; P_08=FOT; P_09=BA3; P_0a=DA3; P_0b=WPF; P_0c=SOS; P_0f=DIR; P_10=RPD; P_11=RPI; P_12=AFD; P_13=AFM; P_14=AFR; P_15=SCL; P_16=PFS; P_19=ADB; P_1a=AWP; P_1b=ASP; P_20=TDM; P_21=IPS; P_22=UPV; P_29=3SD; P_2a=8SC; P_2b=8OB; P_2c=8IC; P_2d=8LD; P_2e=P8C; P_41=OCR; P_42=FTD; P_50=GWP; P_51=GSS; P_52=GDB; P_53=DRW; P_54=GDP; P_55=HMD; P_56=EDU; P_57=STN; P_58=HLP; P_59=COM; P_5a=CFG; P_5b=ANM; P_5c=MUM; P_5d=ENT; P_5e=DVU; P_60=PRE; P_6b=BIO; P_6d=DVR; P_6e=PRE; P_6f=HDV; P_80=GEZ; P_81=GE1; P_82=GEO; P_83=GE3; P_84=GE4; P_85=GE5; P_86=GE6; P_87=GE7; P_88=GE8; P_89=GE9; P_8a=GEA; P_8b=GEB; P_8c=GEC; P_8d=GED; P_8e=GEE; P_8f=GEF; P_a0=WP_; P_ab=GSB; P_ac=TDF; P_ad=BDF; P_b0=SRC; P_b1=OBJ; P_b2=LIB; P_b3=S16; P_b4=RTL; P_b5=EXE; P_b6=STR; P_b7=TSF; P_b8=NDA; P_b9=CDA; P_ba=TOL; P_bb=DRV; P_bc=LDF; P_bd=FST; P_bf=DOC; P_c0=PNT; P_c1=PIC; P_c2=ANI; P_c3=PAL; P_c5=OOG; P_c6=SCR; P_c7=CDV; P_c8=FON; P_c9=FND; P_ca=ICN; P_d5=MUS; P_d6=INS; P_d7=MDI; P_d8=SND; P_db=DBM; P_e0=SHK; P_e2=DTS; P_ee=R16; P_ef=PAS; P_f0=CMD; P_f9=P16; P_fa=INT; P_fb=IVR; P_fc=BAS; P_fd=VAR; P_fe=REL; P_ff=SYS;
|
||||||
|
|
||||||
# process filetype
|
# process filetype
|
||||||
if [[ ! $adFile ]]; then
|
if [[ ! $AD && ! $EX ]]; then # no resource fork or metadata
|
||||||
[[ ${3:0:2} == "0x" ]] && ftArg="\$${3:2}" || ftArg="$3"
|
[[ ${3:0:2} == "0x" ]] && ftArg="\$${3:2}" || ftArg="$3"
|
||||||
auxType="$4"
|
auxType="$4"
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ if [[ ( $arg1 == "-p" || $arg1 == "-c" || $arg1 == "-g" || $arg1 == "-e" || $arg
|
|||||||
if [[ ${ftArg:0:1} == '$' ]]; then
|
if [[ ${ftArg:0:1} == '$' ]]; then
|
||||||
fc=$(tr [:upper:] [:lower:] <<< ${ftArg:1:2})
|
fc=$(tr [:upper:] [:lower:] <<< ${ftArg:1:2})
|
||||||
else
|
else
|
||||||
fc=$(decToHex $ftArg | tr [:upper:] [:lower:])
|
fc=$(printf %02X "$ftArg" | tr [:upper:] [:lower:])
|
||||||
fi
|
fi
|
||||||
ftVar="P_$fc";
|
ftVar="P_$fc";
|
||||||
[[ ${!ftVar} ]] && ft=${!ftVar} || ft="\$$fc";
|
[[ ${!ftVar} ]] && ft=${!ftVar} || ft="\$$fc";
|
||||||
@ -258,23 +258,36 @@ if [[ ( $arg1 == "-p" || $arg1 == "-c" || $arg1 == "-g" || $arg1 == "-e" || $arg
|
|||||||
java -Xmx128m -jar "$acPath" -d "$imageArg" $prodosPath &> /dev/null
|
java -Xmx128m -jar "$acPath" -d "$imageArg" $prodosPath &> /dev/null
|
||||||
java -Xmx128m -jar "$acPath" -p "$imageArg" $prodosPath $ft $auxType 2> $acmdStdErr
|
java -Xmx128m -jar "$acPath" -p "$imageArg" $prodosPath $ft $auxType 2> $acmdStdErr
|
||||||
fi
|
fi
|
||||||
else # AppleDouble, get resource fork and file metadata from header file
|
else # AppleDouble or nulib extended, get resource fork and file metadata from header file
|
||||||
|
|
||||||
[[ ! -f $prodosArg ]] && { echoerr "$prodosArg not found."; exit 1; }
|
[[ ! -f $prodosArg ]] && { echoerr "$prodosArg not found."; exit 1; }
|
||||||
[[ ! -f $adFile ]] && { echoerr "Not an AppleDouble file: $adFile"; exit 1; }
|
[[ $AD && ! -f $rFile ]] && { echoerr "Not an AppleDouble file: $rFile"; exit 1; }
|
||||||
|
|
||||||
# get metadata from appleDouble header
|
if [[ $AD ]]; then
|
||||||
[[ $(dd if="$adFile" bs=1 count=1 skip=741 2> /dev/null | wc -c) -gt 0 ]] && isExtFile=1 || isExtFile=
|
# get metadata from AppleDouble header
|
||||||
fileData=$(dd if="$adFile" bs=1 count=24 skip=637 2> /dev/null | xxd -p | tr -d '\n')
|
[[ $(dd if="$rFile" bs=1 count=1 skip=741 2> /dev/null | wc -c) -gt 0 ]] && isExtFile=1 || isExtFile=
|
||||||
ftVar="P_${fileData:34:2}";
|
fileData=$(dd if="$rFile" bs=1 count=24 skip=637 2> /dev/null | xxd -p | tr -d '\n')
|
||||||
|
ftVar="P_${fileData:34:2}";
|
||||||
|
auxType="\$"${fileData:36:4}
|
||||||
|
cDateTime=$(printf %d 0x${fileData:0:8})
|
||||||
|
mDateTime=$(printf %d 0x${fileData:8:8})
|
||||||
|
[[ $(printf %d 0x"${fileData:0:2}") -gt 127 ]] && (( cDateTime-=4294967296 )) # handle negative hex number
|
||||||
|
[[ $(printf %d 0x"${fileData:8:2}") -gt 127 ]] && (( mDateTime-=4294967296 )) # handle negative hex number
|
||||||
|
(( cDateTime+=946684800 )) # convert AD timestamp to Unix timestamp
|
||||||
|
(( mDateTime+=946684800 )) # convert AD timestamp to Unix timestamp
|
||||||
|
else # EX
|
||||||
|
# get metadata from file info
|
||||||
|
[[ -f "$rFile" ]] && isExtFile=1 || isExtFile=
|
||||||
|
ftVar="P_${prodosArg: -6:2}"
|
||||||
|
auxType="\$"${prodosArg: -4}
|
||||||
|
if [[ $osx ]]; then
|
||||||
|
mDateTime=$(stat -f "%m" "$prodosArg")
|
||||||
|
else
|
||||||
|
mDateTime=$(stat -c %Y "$prodosArg")
|
||||||
|
fi
|
||||||
|
cDateTime=$mDateTime
|
||||||
|
fi
|
||||||
[[ ${!ftVar} ]] && ft=${!ftVar} || ft="\$$fc"; # set file type
|
[[ ${!ftVar} ]] && ft=${!ftVar} || ft="\$$fc"; # set file type
|
||||||
auxType="\$"${fileData:36:4}
|
|
||||||
cDateTime=$(printf %d 0x${fileData:0:8})
|
|
||||||
mDateTime=$(printf %d 0x${fileData:8:8})
|
|
||||||
[[ $(printf %d 0x"${fileData:0:2}") -gt 127 ]] && (( cDateTime-=4294967296 )) # handle negative hex number
|
|
||||||
[[ $(printf %d 0x"${fileData:8:2}") -gt 127 ]] && (( mDateTime-=4294967296 )) # handle negative hex number
|
|
||||||
(( cDateTime+=946684800 )) # convert AD timestamp to Unix timestamp
|
|
||||||
(( mDateTime+=946684800 )) # convert AD timestamp to Unix timestamp
|
|
||||||
# convert unix timestamp to ProDOS bitfield yyyyyyymmmmddddd 000hhhhh00mmmmmm
|
# convert unix timestamp to ProDOS bitfield yyyyyyymmmmddddd 000hhhhh00mmmmmm
|
||||||
cDateFields=($(date -d @$cDateTime +"%y %m %d %H %M" 2> /dev/null))
|
cDateFields=($(date -d @$cDateTime +"%y %m %d %H %M" 2> /dev/null))
|
||||||
[[ ! $cDateFields ]] && cDateFields=($(date -r $cDateTime +"%y %m %d %H %M")) # OS X/BSD
|
[[ ! $cDateFields ]] && cDateFields=($(date -r $cDateTime +"%y %m %d %H %M")) # OS X/BSD
|
||||||
@ -286,6 +299,7 @@ if [[ ( $arg1 == "-p" || $arg1 == "-c" || $arg1 == "-g" || $arg1 == "-e" || $arg
|
|||||||
mDateTimeHex=${mDateTimeHex:2:2}${mDateTimeHex:0:2}${mDateTimeHex:6:2}${mDateTimeHex:4:2}
|
mDateTimeHex=${mDateTimeHex:2:2}${mDateTimeHex:0:2}${mDateTimeHex:6:2}${mDateTimeHex:4:2}
|
||||||
|
|
||||||
# create forks and file entry
|
# create forks and file entry
|
||||||
|
### RIGHT HERE PROBLEMS IF #000000 specified and maybe if not
|
||||||
fileName="${prodosPath##*/}"
|
fileName="${prodosPath##*/}"
|
||||||
if [[ $isExtFile ]]; then
|
if [[ $isExtFile ]]; then
|
||||||
dfName=X$(printf %04X $RANDOM $RANDOM $RANDOM)
|
dfName=X$(printf %04X $RANDOM $RANDOM $RANDOM)
|
||||||
@ -295,16 +309,16 @@ if [[ ( $arg1 == "-p" || $arg1 == "-c" || $arg1 == "-g" || $arg1 == "-e" || $arg
|
|||||||
while [[ $fileName == "${prodosPath##*/}" || $rfName == $fileName || $dfName == $fileName ]]; do
|
while [[ $fileName == "${prodosPath##*/}" || $rfName == $fileName || $dfName == $fileName ]]; do
|
||||||
fileName=X$(printf %04X $RANDOM $RANDOM $RANDOM)
|
fileName=X$(printf %04X $RANDOM $RANDOM $RANDOM)
|
||||||
done
|
done
|
||||||
java -Xmx128m -jar "$acPath" -d "$imageArg" "${adFile%*.AppleDouble/*}$dfName" 2> /dev/null
|
java -Xmx128m -jar "$acPath" -d "$imageArg" "${prodosArgParent}$dfName" 2> /dev/null
|
||||||
dd if="$prodosArg" 2> /dev/null | java -Xmx128m -jar "$acPath" -p "$imageArg" "${adFile%*.AppleDouble/*}$dfName" $00 2> $acmdStdErr
|
dd if="$prodosArg" 2> /dev/null | java -Xmx128m -jar "$acPath" -p "$imageArg" "${prodosArgParent}$dfName" $00 2> $acmdStdErr
|
||||||
java -Xmx128m -jar "$acPath" -d "$imageArg" "${adFile%*.AppleDouble/*}$rfName" 2> /dev/null
|
java -Xmx128m -jar "$acPath" -d "$imageArg" "${prodosArgParent}$rfName" 2> /dev/null
|
||||||
dd if="$adFile" bs=741 skip=1 2> /dev/null | java -Xmx128m -jar "$acPath" -p "$imageArg" "${adFile%*.AppleDouble/*}$rfName" $00 2> $acmdStdErr
|
dd if="$rFile" bs=1 skip=$(( 0$AD ? 741 : 0 )) 2> /dev/null | java -Xmx128m -jar "$acPath" -p "$imageArg" "${prodosArgParent}$rfName" $00 2> $acmdStdErr
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# create file entry, then find it
|
# create file entry, then find it
|
||||||
java -Xmx128m -jar "$acPath" -d "$imageArg" "${adFile%*.AppleDouble/*}$fileName" 2> /dev/null
|
java -Xmx128m -jar "$acPath" -d "$imageArg" "${prodosArgParent}$fileName" 2> /dev/null
|
||||||
[[ $isExtFile ]] && ddsrc="if=/dev/zero bs=512 count=1" || ddsrc="if=$prodosArg"
|
[[ $isExtFile ]] && ddsrc="if=/dev/zero bs=512 count=1" || ddsrc="if=$prodosArg"
|
||||||
dd $ddsrc 2> /dev/null | java -Xmx128m -jar "$acPath" -p "$imageArg" "${adFile%*.AppleDouble/*}$fileName" "$ft" "$auxType" 2> $acmdStdErr
|
dd $ddsrc 2> /dev/null | java -Xmx128m -jar "$acPath" -p "$imageArg" "${prodosArgParent}$fileName" "$ft" "$auxType" 2> $acmdStdErr
|
||||||
# thx to http://unix.stackexchange.com/a/122945/99697 for perl alternative to broken --byte-offset in grep 2.5.1 (e.g. in OS X)
|
# thx to http://unix.stackexchange.com/a/122945/99697 for perl alternative to broken --byte-offset in grep 2.5.1 (e.g. in OS X)
|
||||||
fileEntryOffset=$(perl -n0777e "print pos()-length('.$fileName') while /.$fileName/g" < "$imageArg")
|
fileEntryOffset=$(perl -n0777e "print pos()-length('.$fileName') while /.$fileName/g" < "$imageArg")
|
||||||
fileEntry=$(dd if="$imageArg" bs=1 count=39 skip=$fileEntryOffset 2> /dev/null | xxd -p | tr -d '\n')
|
fileEntry=$(dd if="$imageArg" bs=1 count=39 skip=$fileEntryOffset 2> /dev/null | xxd -p | tr -d '\n')
|
||||||
@ -324,7 +338,7 @@ if [[ ( $arg1 == "-p" || $arg1 == "-c" || $arg1 == "-g" || $arg1 == "-e" || $arg
|
|||||||
# mark as deleted
|
# mark as deleted
|
||||||
echo -n -e \\x0${dfEntry:1:1} \
|
echo -n -e \\x0${dfEntry:1:1} \
|
||||||
| dd of="$imageArg" conv=notrunc bs=1 seek=$(( dfOffset+0 )) 2> /dev/null
|
| dd of="$imageArg" conv=notrunc bs=1 seek=$(( dfOffset+0 )) 2> /dev/null
|
||||||
|
|
||||||
# find resource fork, copy storage type, key block, block size, length to extended key block mini-entry
|
# find resource fork, copy storage type, key block, block size, length to extended key block mini-entry
|
||||||
# then mark as available/deleted
|
# then mark as available/deleted
|
||||||
rfOffset=$(perl -n0777e "print pos()-length('.$rfName') while /.$rfName/g" < "$imageArg")
|
rfOffset=$(perl -n0777e "print pos()-length('.$rfName') while /.$rfName/g" < "$imageArg")
|
||||||
@ -337,7 +351,7 @@ if [[ ( $arg1 == "-p" || $arg1 == "-c" || $arg1 == "-g" || $arg1 == "-e" || $arg
|
|||||||
# mark as deleted
|
# mark as deleted
|
||||||
echo -n -e \\x0${rfEntry:1:1} \
|
echo -n -e \\x0${rfEntry:1:1} \
|
||||||
| dd of="$imageArg" conv=notrunc bs=1 seek=$(( rfOffset+0 )) 2> /dev/null
|
| dd of="$imageArg" conv=notrunc bs=1 seek=$(( rfOffset+0 )) 2> /dev/null
|
||||||
|
|
||||||
# reduce active file count in directory by two
|
# reduce active file count in directory by two
|
||||||
parentDirKeyBlockOffset=$(( ( ( $(printf %d 0x"${fileEntry:76:2}") * 256 ) + $(printf %d 0x"${fileEntry:74:2}") * 512 ) ))
|
parentDirKeyBlockOffset=$(( ( ( $(printf %d 0x"${fileEntry:76:2}") * 256 ) + $(printf %d 0x"${fileEntry:74:2}") * 512 ) ))
|
||||||
fileCountHex=$(dd if="$imageArg" bs=1 count=2 skip=$((parentDirKeyBlockOffset+4+33)) 2> /dev/null | xxd -p)
|
fileCountHex=$(dd if="$imageArg" bs=1 count=2 skip=$((parentDirKeyBlockOffset+4+33)) 2> /dev/null | xxd -p)
|
||||||
@ -345,7 +359,7 @@ if [[ ( $arg1 == "-p" || $arg1 == "-c" || $arg1 == "-g" || $arg1 == "-e" || $arg
|
|||||||
fileCountHex=$(printf %04X $((fileCount - 2)))
|
fileCountHex=$(printf %04X $((fileCount - 2)))
|
||||||
echo -n -e \\x${fileCountHex:2:2}\\x${fileCountHex:0:2} \
|
echo -n -e \\x${fileCountHex:2:2}\\x${fileCountHex:0:2} \
|
||||||
| dd of="$imageArg" conv=notrunc bs=1 seek=$((parentDirKeyBlockOffset+4+33)) 2> /dev/null
|
| dd of="$imageArg" conv=notrunc bs=1 seek=$((parentDirKeyBlockOffset+4+33)) 2> /dev/null
|
||||||
|
|
||||||
# update extended file metadata
|
# update extended file metadata
|
||||||
|
|
||||||
# storage type (5), name length, name
|
# storage type (5), name length, name
|
||||||
@ -365,9 +379,11 @@ if [[ ( $arg1 == "-p" || $arg1 == "-c" || $arg1 == "-g" || $arg1 == "-e" || $arg
|
|||||||
fileEntry=${fileEntry:0:48}${cDateTimeHex}${fileEntry:56:10}${mDateTimeHex}${fileEntry:74:4}
|
fileEntry=${fileEntry:0:48}${cDateTimeHex}${fileEntry:56:10}${mDateTimeHex}${fileEntry:74:4}
|
||||||
|
|
||||||
# put casemask for mixed case filename in file entry
|
# put casemask for mixed case filename in file entry
|
||||||
|
[[ $EX ]] && prodosArg="${prodosArg%#*}"
|
||||||
if [[ "${prodosPath##*/}" != "${prodosArg##*/}" ]]; then # mixed case
|
if [[ "${prodosPath##*/}" != "${prodosArg##*/}" ]]; then # mixed case
|
||||||
caseMaskDec=32768
|
caseMaskDec=32768
|
||||||
mixedName="${prodosArg##*/}"
|
mixedName="${prodosArg##*/}"
|
||||||
|
[[ $EX ]] && mixedName="${mixedName%#*}"
|
||||||
for (( i=0; i<${#mixedName}; i++ )); do
|
for (( i=0; i<${#mixedName}; i++ )); do
|
||||||
[[ "${mixedName:$i:1}" == $(tr [:lower:] [:upper:] <<< "${mixedName:$i:1}") ]] # $? == 0 means uppercase
|
[[ "${mixedName:$i:1}" == $(tr [:lower:] [:upper:] <<< "${mixedName:$i:1}") ]] # $? == 0 means uppercase
|
||||||
(( caseMaskDec+=$(( $? * (2**(14-i)) )) ))
|
(( caseMaskDec+=$(( $? * (2**(14-i)) )) ))
|
||||||
|
Loading…
Reference in New Issue
Block a user