(set @default-dest "Workbench:")

(if (< (getversion "LIBS:version.library") (* 38 65536))
	(abort "MultiFileSystem requires\nWorkbench 2.1 or higher")
)

(copylib
	(prompt "Copying mfs-handler")
	(help @copylib-help)
	(source "l/mfs-handler")
	(dest "L:")
	(confirm)
)

(copylib
	(prompt "Copying MFSMount")
	(help @copylib-help)
	(source "c/MFSMount")
	(dest "C:")
	(confirm)
)

(copylib
	(prompt "Copying MFS commodity")
	(help @copylib-help)
	(source "Tools/Commodities/MFS")
	(dest "Workbench:Tools/Commodities")
	(infos)
	(confirm)
)

(makedir "DEVS:DOSDrivers/DF0"
	(prompt "Creating drawer \"DEVS:DOSDrivers/DF0\"")
	(help @makedir-help)
	(infos)
	(confirm)
)

(if (= (exists "DEVS:DOSDrivers/DF0") 2)
	(
		(rename "DEVS:DOSDrivers/PC0" "DEVS:DOSDrivers/DF0/PC0"
			(prompt "Moving PC0 to drawer \"DEVS:DOSDrivers/DF0\"")
			(help @rename-help)
			(confirm)
		)

		(if (= (exists "DEVS:DOSDrivers/DF0/PC0") 1)
			(rename "DEVS:DOSDrivers/PC0.info" "DEVS:DOSDrivers/DF0/PC0.info")
		)
	)
)

(if (= (run "C:Assign DF1: EXISTS" (safe)) 0)
	(
		(makedir "DEVS:DOSDrivers/DF1"
			(prompt "Creating drawer \"DEVS:DOSDrivers/DF1\"")
			(help @makedir-help)
			(infos)
			(confirm)
		)

		(if (= (exists "DEVS:DOSDrivers/DF1") 2)
			(
				(rename "DEVS:DOSDrivers/PC1" "DEVS:DOSDrivers/DF1/PC1"
					(prompt "Moving PC1 to drawer \"DEVS:DOSDrivers/DF1\"")
					(help @rename-help)
					(confirm)
				)

				(if (= (exists "DEVS:DOSDrivers/DF1/PC1") 1)
					(rename "DEVS:DOSDrivers/PC1.info" "DEVS:DOSDrivers/DF2/PC1.info")
				)
			)
		)
	)
)

(if (= (run "C:Assign DF2: EXISTS" (safe)) 0)
	(
		(makedir "DEVS:DOSDrivers/DF2"
			(prompt "Creating drawer \"DEVS:DOSDrivers/DF2\"")
			(help @makedir-help)
			(infos)
			(confirm)
		)

		(if (= (exists "DEVS:DOSDrivers/DF2") 2)
			(
				(rename "DEVS:DOSDrivers/PC2" "DEVS:DOSDrivers/DF2/PC2"
					(prompt "Moving PC2 to drawer \"DEVS:DOSDrivers/DF2\"")
					(help @rename-help)
					(confirm)
				)

				(if (= (exists "DEVS:DOSDrivers/DF2/PC2") 1)
					(rename "DEVS:DOSDrivers/PC2.info" "DEVS:DOSDrivers/DF2/PC2.info")
				)
			)
		)
	)
)

(if (= (run "C:Assign DF3: EXISTS" (safe)) 0)
	(
		(makedir "DEVS:DOSDrivers/DF3"
			(prompt "Creating drawer \"DEVS:DOSDrivers/DF3\"")
			(help @makedir-help)
			(infos)
			(confirm)
		)

		(if (= (exists "DEVS:DOSDrivers/DF3") 2)
			(
				(rename "DEVS:DOSDrivers/PC3" "DEVS:DOSDrivers/DF3/PC3"
					(prompt "Moving PC3 to drawer \"DEVS:DOSDrivers/DF3\"")
					(help @rename-help)
					(confirm)
				)

				(if (= (exists "DEVS:DOSDrivers/DF3/PC3") 1)
					(rename "DEVS:DOSDrivers/PC3.info" "DEVS:DOSDrivers/DF3/PC3.info")
				)
			)
		)
	)
)

(startup "MultiFileSystem"
	(prompt "Adding a line to S:user-startup")
	(help @startup-help)
	(command "C:MFSMount DEVS:DOSDrivers/~(#?.info)")
)
