; $VER: InstallAExplorer_Update 1.1
; Cloanto Amiga Explorer Update Installer Script
; Copyright © 1996, 1997 Cloanto Italia srl
; Cloanto is a registered trademark of Cloanto Italia srl
; "Installer and Installer project icon Copyright © 1991-1993 Commodore-Amiga, Inc. All Rights Reserved
;  Reproduced and distributed under license from Commodore"
; New installer icon design Copyright © 1994 Cloanto Italia srl

(set #which-dir
	"Please indicate the directory where Amiga Explorer is installed:")

(set #which-dir-help
	(cat "\nThis program updates the \"AExplorer\" program file."
	"\n\nPlease specify the full path of the installed Amiga "
	"Explorer software, including the final \"AExplorer\" directory name "
	"(or other, if a different drawer name was used).\n\n"
	@askdir-help))

(set #message-aexplorernotok
	"\nThis update was not designed for the selected Amiga Explorer program file. It will not be updated.")

(set #error-aexplorer
	"\nAmiga Explorer program file could not be found. It will not be updated.")

(set #busy-aexplorer
	"Updating Amiga Explorer program file.")

(set #busy-icon
	"Updating Amiga Explorer Workbench icon (ToolTypes).")

(if (= (getassign "AF_Disk" "av") "") (set aexplorer_dest "") (set aexplorer_dest (getassign "AF_Disk" "av")))
(if (AND (<> (getdevice aexplorer_dest)(getdevice "RAM:"))(< (getdiskspace aexplorer_dest) 2048)) (set aexplorer_dest ""))
(if (= aexplorer_dest "") (set aexplorer_dest @default-dest))

(set aexplorer_dest (askdir
	(prompt #which-dir)
	(help #which-dir-help)
	(default aexplorer_dest)
	(newpath)
))

(set target1 (tackon aexplorer_dest "AExplorer"))
(if (<> (exists target1) 1) (if (= (exists target1) 2) (set aexplorer_dest target1)))
(set @default-dest aexplorer_dest)

(set target1 (tackon aexplorer_dest "AExplorer"))
(if (<> (exists target1) 1) (message #error-aexplorer) (
	(if (AND (AND (<> (getsize target1) 19248) (<> (getsize target1) 20624)) (<> (getsize target1) 27744)) (message #message-aexplorernotok) (

		(if (= (getsize target1) 19248) (
			(working #busy-aexplorer)
			(set runstring (cat "spatch >NIL: <NIL: \"-o" target1 "\" -pAE10-11a.pch \"" target1 "\""))
			(run runstring)
		))

		(if (= (getsize target1) 20624) (
			(working #busy-aexplorer)
			(set runstring (cat "spatch >NIL: <NIL: \"-o" target1 "\" -pAE11-11c.pch \"" target1 "\""))
			(run runstring)

		(working #busy-icon)
		(copyfiles
			(source "icons/AExplorer.info")
			(dest (pathonly target1))
			(optional "nofail" "force")
			(nogauge)
			)
		))


		(if (= (getsize target1) 27744) (
			(working #busy-aexplorer)
			(set runstring (cat "spatch >NIL: <NIL: \"-o" target1 "\" -pAE11-11d.pch \"" target1 "\""))
			(run runstring)
		))


		(exit)
	))
))

(exit (quiet))
