.key dest/a,test/s
.bra [
.ket ]
; This script will look in [dest]fonts for all the files corresponding
; to those in AmigaFonts2.0:fonts, and add up all the space those files
; use (plus one block each for the directory entry).
; It sets the environment variable fontreturn based on its determination
; of whether the fonts will fit when copied to the destination.
; SIDE EFFECT: it leaves you CD'd to RAM:.  Eliminating the side-effect
; would mean an extra disk swap (asking for 2.0Install:).
;
cd AmigaFonts2.0:fonts
set total 0
unset size
alias getsize list >env:size lformat "%b"
echo "Checking which files on AmigaFonts2.0: need to be copied..."
list >t:sumsizes all files lformat "if exists [dest]fonts/%p%n*Ngetsize [dest]fonts/%p%n*Nset total *`eval *$size+*$total+1*`*Nendif"
echo "Figuring out how much room will be reclaimed during overwriting..."
execute t:sumsizes
c:delete t:sumsizes quiet
cd RAM:

; check if we have enough space for fonts
set size `info "[dest]"`
set size `echo "$size" first 92 len 7`
if "[test]" NOT EQ ""
    echo "There are $size blocks free on $target,"
    echo "plus $total blocks that would be reclaimed."
    echo "We need approximately 1525 blocks total."
endif
if val $size GT `eval 1525-$total`
set fontreturn 0
else
set fontreturn 5
endif
unalias getsize
unset total
unset size
