@if "%9x" == "x" goto NOPARAMS

@REM set TEMPG=genfile
@set TEMPG=c:\Projects\tar\Win32\Debug\genfile.exe

@REM AT_TAR_CHECK([
@REM exec <&-
@REM genfile --sparse --file sparsefile $2 || AT_SKIP_TEST
@REM TAR_MVP_TEST(1.0, [0 ABCDEFGH 1M ABCDEFGHI], [0 ABCDEFG 1M ABCDEFGHI])
@REM genfile --sparse --file sparsefile 0 ABCDEFGH 1M ABCDEFGHI

%TEMPG% --sparse --file sparsefile %2 %3 %4 %5
@if ERRORLEVEL 1 goto TERR1
@if NOT EXIST sparsefile goto TERR2

@echo Pass 1: Split between data blocks ...
@echo.
@echo Create archive
%TEMPT% --sparse --sparse-version=%1 -c --record-size=512 -M -L6 -f arc.1 -f arc.2 -f arc.3 sparsefile 
@echo.
@echo.
@echo.
@ask "Continue ... y/n"
@if ERRORLEVEL 1 goto CONT1
@goto END
:CONT1
@echo.
@echo Test archive
%TEMPT% -t -M -f arc.1 -f arc.2 -f arc.3
@echo.
@echo.
@echo.
@ask "Continue ... y/n"
@if ERRORLEVEL 1 goto CONT2
@goto END
:CONT2
@echo.
@echo Compare archive
@echo.
%TEMPT% -d -M -f arc.1 -f arc.2 -f arc.3

@echo.
@echo.
@echo.
@ask "Continue ... y/n"
@if ERRORLEVEL 1 goto CONT3
@goto END
:CONT3
@echo.
@echo Pass 2: Split within a data block
%TEMPG% --sparse --file sparsefile %6 %7 %8 %9
@echo Create archive
%TEMPT% --sparse --sparse-version=%1 -c --record-size=512 -M -L6 -f arc.1 -f arc.2 -f arc.3 sparsefile 
@echo Test archive
%TEMPT% -t -M -f arc.1 -f arc.2 -f arc.3
@echo Compare archive
%TEMPT% -d -M -f arc.1 -f arc.2 -f arc.3

@goto END

:NOPARAMS
@echo ERROR: This file requires 9 parameters ...
@goto WAIT

:TERR1
@echo ERROR: Exit %ERRORLEVEL% ...
@echo ERROR: creating sparse file ...
@goto WAIT

:TERR2
@echo ERROR: sparsefile does not exist ...
@goto WAIT

:WAIT
@pause
@goto END

:END
