@ECHO off

if "%1" == "" GOTO USAGE
if "%2" == "FTP" GOTO CPFTP
if "%2" == "" GOTO USAGE
if "%3" == "FULL" GOTO CPFULL 
if "%3" == "MIN"  GOTO CPMIN


:USAGE
cls
echo.
echo Usage is : 
echo     INTALL.BAT [root drive] [target drive]  FULL or MIN 
echo.
echo     with (target drive) follows the form below :
echo        install.bat e: c: FULL
echo        install.bat e: c:\simulator FULL
echo.
echo If you get AFS files from a FTP site, follow the syntax below :
echo.
echo     INTALL.BAT [Absolute AFS directory] FTP
echo        install.bat e:\AFS FTP
echo. 
echo FULL option is recommended, it allows patches and
echo version updates on your hard disk, but in order to save
echo hard disk space, you can choose MIN as installation option.
echo.
echo If you choose MIN as installation option, you must re-install
echo AFS with FULL option if you get an update or a patch.
echo.
pause
echo This script will create the AFS directory in (target drive)
echo with either partial (MIN) or complete (FULL) installation.
echo.
echo FTP option is only if you get AFS from an FTP site, it configures
echo AFS to run in current directory. This directory must contains
echo uncompressed AFS files.
echo.
goto fin

:CPMIN

echo install AFS from drive %1 to %2\AFS
pause

mkdir %2\AFS
mkdir %2\AFS\pilot
mkdir %2\AFS\aircraft
mkdir %2\AFS\logs
mkdir %2\AFS\dat


xcopy /s /y /e /v pilot %2\AFS\pilot
xcopy /s /y /e /v aircraft %2\AFS\aircraft
xcopy /s /y /e /v logs %2\AFS\logs
copy dat\*.dat %2\AFS\DAT
copy dat\*.cnf %2\AFS\DAT

echo %1 >%2\AFS\afs.bat
tools\echon cd >>%2\AFS\afs.bat
chdir >>%2\AFS\afs.bat
echo afs.exe %2\AFS >>%2\AFS\afs.bat
echo register.exe %2\afs >%2\AFS\register.bat
goto fin

:CPFULL
echo install AFS from drive %1 to %2\AFS
pause
mkdir %2\AFS
mkdir %2\AFS\pilot
mkdir %2\AFS\aircraft
mkdir %2\AFS\logs
mkdir %2\AFS\dat
mkdir %2\AFS\airport
mkdir %2\AFS\board
mkdir %2\AFS\hlp
mkdir %2\AFS\sound
mkdir %2\AFS\texture
mkdir %2\AFS\scene
mkdir %2\AFS\dem
xcopy /s /y /e /v pilot %2\AFS\pilot
xcopy /s /y /e /v aircraft %2\AFS\aircraft
xcopy /s /y /e /v logs %2\AFS\logs
xcopy /s /y /e /v dat %2\AFS\dat
xcopy /s /y /e /v airport %2\AFS\airport
xcopy /s /y /e /v board %2\AFS\board
xcopy /s /y /e /v hlp %2\AFS\hlp
xcopy /s /y /e /v sound %2\AFS\sound
xcopy /s /y /e /v texture %2\AFS\texture
xcopy /s /y /e /v scene %2\AFS\scene
copy *.* %2\AFS

echo %2 >%2\AFS\afs.bat
tools\echon cd >>%2\AFS\afs.bat
chdir >>%2\AFS\afs.bat
echo afs.exe %2\AFS >>%2\AFS\afs.bat
echo register %2\AFS >%2\AFS\register.bat
goto fin

:CPFTP
echo install AFS to run in %1
pause
echo afs.exe %1 >afs.bat
echo register %1 > register.bat
echo.
echo To run AFS, change current directory to %1 and just type AFS.BAT
goto fin1

:fin
echo AFS successfully installed in %2
cd %2\AFS
echo.
echo To run AFS, change current directory to %2\AFS and just type AFS.BAT
:fin1
echo To register, run register.bat and fill order.txt.
echo Don't hesitate to contact us, send your suggestions, comments and
echo creticisms at afs-sim@pacwan.mm-soft.fr.
echo Check our web server at www.mm-soft.fr/raw/afs-sim
echo ---- Thank you for you support. ----
echo.

