@setlocal
@REM 20091111 - Add a boost header...
@if "%1x" == "x" goto HELP
@set TEMP1=C:\FGCVS\boost-trunk\boost
@set TEMP2=boost
@set TEMP3=%1
@set TEMPF=%1
@set TEMPC=0
@set TEMPP=
:RPT
@shift
@if "%1x" == "x" goto GOTCMD
@set TEMPP=%TEMP3%
@set TEMP3=%TEMP3%\%1
@set TEMPF=%1
@goto RPT
:GOTCMD

@REM Check the SOURCE path exists
@if NOT EXIST %TEMP1%\. goto ERR1
@REM Check the SOURCE file exists
@if NOT EXIST %TEMP1%\%TEMP3% goto ERR2
@REM Check the primary DESTINATION folder exists
@if NOT EXIST %TEMP2%\. goto ERR3

@echo Copy %TEMP3% to %TEMP2%\%TEMP3%
@echo path: %TEMPP%
@if NOT EXIST %TEMP2%\%TEMPP%\. goto NODPATH

:DOCOPY
@echo file: %TEMPF%
@if NOT EXIST %TEMP2%\%TEMPP%\%TEMPF% goto COPYIT
@echo SOURCE
@dir %TEMP1%\%TEMP3%
@echo DESTINATION
@dir %TEMP2%\%TEMPP%\%TEMPF%
@echo NOTE ABOVE: File already exists!
@echo *** OVERWRITE? *** Ctrl+C to ABORT.
@pause
@echo Proceeding with the COPY...
:COPYIT
copy %TEMP1%\%TEMP3% %TEMP2%\%TEMPP%\%TEMPF%
@goto END

:NODPATH
@echo Path %TEMP2%\%TEMPP% does NOT exist, and attempting creation...
md %TEMP2%\%TEMPP%
@if NOT EXIST %TEMP2%\%TEMPP%\. goto NODPATH2
@goto DOCOPY

:NODPATH2
@echo ERROR: Unable to create PATH... perhaps multiple levels...
@echo Must manually create this path [%TEMP2%\%TEMPP%]!
@pause
@goto END


:ERR1
@echo ERROR: Can NOT locate SOURCE directory [%TEMP1%]... check name, location
@goto END

:ERR2
@echo ERROR: Can NOT locate SOURCE file [%TEMP1%\%TEMP3%]... check name, location
@goto END

:ERR3
@echo ERROR: Can NOT locate DESTINATION directory [%TEMP2%\.]... check name, location
@goto END

:HELP
@echo Enter the file name to copy, changing the path separators to a space,
@echo and without the leading 'boost' folder...
@echo E.G. to add a 'missing' boost/format/group.hpp, use -
@echo boostadd format format_implementation.hpp
@echo If multiple levels of path, and the destination folder
@echo does not presently exist, an attempt will be made to
@echo create it, but this can fail, and then the path must
@echo be manually created.
@goto END

:END
@endlocal
