;;----------------------------------------------------------------------------
;;
;; Remove-BarNone - BarNone removal script for Installer
;;
;; Copyright © 1996 Steve Koren, All Right reserved.
;;
;; Use following Icon tooltypes / Command line options:
;; APPNAME=BarNone
;; MINUSER=AVERAGE
;;----------------------------------------------------------------------------

(complete 0)

(set locale 0)

(set #welcome           (cat "Welcome to the " @app-name " removal process."))
(set #removing          (cat "Removing " @app-name " files..."))
(set #notfound          (cat "Unable to find install directory."))
(set #userstop          (cat "User stopped removal."))
(set #danger            (cat "WARNING: This process will remove " @app-name
                             " from your system.  Do you wish to proceed?\n\n"
                             "NOTE: Please save your keyfile, since this "
                             "script will remove the entire BarNone program "
                             "from your system.\n\n"
                             "NOTE: If you have BarNone drawers open in "
                             "workbench or otherwise locked, this script "
                             "will not be able to remove them."))

(set #delwbs            (cat "Deleting BarNone.info from WBStartup."))
(set #delenv            (cat "Deleting BarNone from env: and envarc:"))
(set #deldir            (cat "Deleting %s directory."))

;=============================================================================
; Removal procedure
;=============================================================================

(welcome #welcome)

; -- select our install dir --------------------------------------------------

(set LastDir "")
(set BN-Dir  "")

(if (exists "ENV:BarNone/BN-Dir")
    ((set LastDir (getenv "BarNone/BN-Dir"))
     (if (not (exists (tackon LastDir "BarNone/BarNone")))
         (set LastDir ""))))

(complete 10)
(set Reuse 0)
(if (= LastDir "") (abort #notfound))

(set BN-Dir (tackon LastDir "BarNone"))

(if (not (exists (tackon BN-Dir "BarNone")))
    (abort #notfound))


; -- ask user whether to stop ------------------------------------------------

(complete 20)

(if (not (askbool (prompt #danger)
                  (help @askbool-help)
                  (default 1)))
    (abort #userstop))


; -- really remove stuff -----------------------------------------------------

(set @execute-dir "ram:")

(run (prompt #delwbs)
     (help @run-help)
     (confirm)
     "c:delete" ">nil:" "SYS:WBStartup/BarNone#?")

(run (prompt (#deldir BN-Dir))
     (help @run-help)
     (confirm)
     "c:delete" ">nil:" BN-Dir (cat BN-Dir ".info") "ALL")

(complete 80)

(run (prompt #delenv)
     (help @run-help)
     (confirm)
     "c:delete" ">nil:" "ENV:BarNone" "ENVARC:BarNone" "ALL")

(complete 100)

(exit)
