/
Cool3/bin/
#!/bin/csh

# Set areapath equal to your "area" dir.
# Set back equal to your areabackup dir.
# Use and enjoy.  :)

set areapath = ./
set back = ~/back/backarea

if ( -e "$areapath/Mkbk_a" ) then
    ;
else
    cp -i ./Mkbk_a $areapath/Mkbk_a
endif

cd $areapath
if ( "$1" == "" ) then
    echo Syntax: Mkbk_a "<"directory">"
    exit 1
endif
if ( -e "$1" ) then
    echo Error: Target directory already exists!
    exit 1
else
    echo Creating directory...
    mkdir "$1"
    echo Copying files.........
    if ( -e "area.lst" ) then
	cp -i area.lst "$1"
    else
	echo Error: Area list not found.
	exit 1
    endif
    if ( -e "limbo.are" ) then
	;
    else
	echo Error: limbo.are (default objects) not found.
	exit 1
    endif
    if ( -e "help.are" ) then
	;
    else
	echo Error: help.are (default helps) not found.
	exit 1
    endif
    if ( -e "olc.hlp" ) then
	cp -i *.hlp "$1"
    else
	echo Warning: Sample .hlp (help data) file not found.  This may be normal.
    endif
    if ( -e "midgaard.are" ) then
	cp -i *.are "$1"
    else
	echo Error: Sample .are file not found.
	exit 1
    endif
    if ( -e "Mkbk_a" ) then
	cp -i Mkbk_a "$1"
    else
	echo Error: Mkbk_a "("this file")" not found.
	exit 1
    endif
    if ( -e "notes.not" ) then
	cp -i *.not "$1"
    else
	echo Error: Sample .not (notes) file not found.
	exit 1
    endif
    if ( -e "wizlist.txt" ) then
	cp -i *.txt "$1"
    else
	echo Warning: Sample .txt file not found.  This may be normal.
    endif
    if ( -e "Independent.cln" ) then
	cp -i *.cln "$1"
    else
	echo Warning: Sample .cln \(clan data\) file not found.  This may be normal.
    endif
    cd "$1"
    echo Beginning TAR file creation process....
    tar -cWf "$1"_area.tar *
    echo Beginning GZ file creation process..........
    gzip -9 "$1"_area.tar
    echo Removing temporary files...
    rm -f *.are
    rm -f *.not
    rm -f *.txt
    rm -f *.cln
    rm -f *.hlp
    rm -f area.lst
    rm -f Mkbk_a
    set newtargz = $back/"$1"_area.tar.gz
    if ( -e $newtargz ) then
	echo File already exists in $back.
	echo Please manually move "$1"_area.tar.gz to your backup dir.
    else
	mv "$1"_area.tar.gz $back
	cd ../
	rmdir "$1"
	echo Backup file process complete.
    endif
    chmod 600 "$newtargz"
endif

if ( "$2" != "Mkback_main" ) then
echo Mkback ""area"" dir submodule:
echo copyright "("c")" 1998 Daniel Reif, dan@betterbox.net
endif