@if NOT EXIST setup.bat goto ERR1
call setup
call mdd temp
@if NOT EXIST ..\extrac05.bat goto ERR2

@echo Creating a 'list' file ...
@echo jeden > list
@echo cztery >> list

@echo Generating a set of files ...
genfile --length 118 --file jeden
genfile --length 223 --file dwa
genfile --length 517 --file trzy
genfile --sparse --file sparsefile 0 ABCD 1M EFGH 2000K IJKL
genfile --length 110 --file cztery
@if NOT EXIST jeden goto ERR3
@if NOT EXIST sparsefile goto ERR3

@echo Creating the archive ...
%TEMPT% cf archive -H posix jeden dwa trzy cztery
@if NOT EXIST archive goto ERR4

@echo.
@echo List of archive contents ...
%TEMPT% -tf archive
md dir
@if NOT EXIST dir\nul goto ERR5
cd dir
%TEMPT% xvfT ../archive ../list
@if ERRORLEVEL 1 goto ERR6
@cd ..
@if NOT EXIST dir\jeden goto ERR7
@if NOT EXIST dir\cztery goto ERR7
@echo Extraction to dir folder appears ok ...
genfile --stat=name,sparse jeden
genfile --stat=name,sparse dir/jeden
@echo Neither should be sparse ... that is 'jeden 0' is output in both cases ...

@cd ..
@goto END

:ERR1
@echo Can NOT locate setup.bat ... check name, location ...
@goto END

:ERR2
@echo mdd.bat missing, or failed ... check name, location ...
@goto END

:ERR3
@echo ERROR: Failed to create file using genfile ... maybe genfile is NOT in the PATH ...
@goto WAIT

:ERR5
@echo ERROR: Failed to create dir directory ...
@goto WAIT

:ERR4
@echo ERROR: Failed to create archive ...
@goto WAIT

:ERR6
cd ..
@echo ERROR: Extract Failed ...
@goto WAIT

:ERR7
@echo ERROR: Extraction of the files failed ...
@goto WAIT


:WAIT
@pause
cd ..
@goto END

:END
