echo off
if "%1"=="" goto usage
if "%2"=="" goto usage
goto start
:usage
echo This command installs the program by copying the files from floppy
echo disks, to your hard disk. If you have already done this, no further
echo installation is needed - type LOTF to run the game, or README for more
echo information.
echo.
echo To copy the files to the hard disk, enter:
echo.
echo   INSTALL source-drive destination-drive [optional-directory-name]
echo.
echo The directory defaults to \LOTF if it is not specified.
echo.
echo E.g. 
echo.
echo   INSTALL A: C:
echo.
echo to copy the files from the disk in drive A:, to the directory \LOTF 
echo on drive C:.
echo.
echo The destination directory is created if it does not already exist. Note
echo that if a path is specified, such as \GAMES\LOTF, only the final
echo subdirectory can be created - the remaining directories must already
echo exist (\GAMES in this example).
goto done

:start
if not exist %1lotfdsk1.id goto badsrc

if "%3"=="" goto defdir

rem Check/create user specified directory
if not exist %2%3\nul echo Creating directory %2%3...
if not exist %2%3\nul mkdir %2%3
if not exist %2%3\nul goto dirfail

if exist %2%3\hiscore.dat copy %2%3\hiscore.dat %2%3\hiscore.old
echo Copying 'Disk 1' files to %2%3...
xcopy %1*.* %2%3
if errorlevel 1 goto copyfail
%2
cd %3

rem 'Chain' to next batch file for copying disk 2. This must be run from the
rem hard disk, with the destination directory current. No return if 
rem successful.
inst2 %1 %2 %3 DSK2
goto dsk2fail

:defdir
rem Check/create default directory
if not exist %2\LOTF\nul echo Creating directory %2\LOTF...
if not exist %2\LOTF\nul mkdir %2\LOTF
if not exist %2\LOTF\nul goto dirfail
if exist %2\LOTF\hiscore.dat copy %2\LOTF\hiscore.dat %2\LOTF\hiscore.old
echo Copying 'Disk 1' files to %2\LOTF...
xcopy %1*.* %2\LOTF
if errorlevel 1 goto copyfail
%2
cd \LOTF
inst2 %1 %2 \LOTF DSK2
goto dsk2fail

:badsrc
echo INSTALL: The source drive does not contain the program files.
echo.
echo Type INSTALL, without any arguments, for instructions.
goto done

:dirfail
echo INSTALL: Unable to create destination directory.
goto done

:dsk2fail
echo INSTALL: Failed to install 'Disk 2' files.
goto done

:copyfail
echo INSTALL: File copy failed.

:done
