#! /bin/sh
#
# Reconstructs zoo archive(s) to lharc archive(s)
# using /tmp/ for temporary storage.
# The .zoo extension should not be given explicitly.
# Before use, check that the zoo archive(s) aren't damaged: zoo Lm *
#
# M. Bergman  1990-03-28
#
if [ $# -lt 1 ]
then
   echo "Usage: zoo2lzh <zoo archive file {zoo archive file}...>"
   echo "	You must have rw permission both to the zoo archive(s)"
   echo "	*and* the catalog(s) they are in."
   echo "	The .lzh file(s) will have the default permissons."
   echo ""
   exit 1
fi
for ARG do
   if [ -w $ARG.zoo -a -r $ARG.zoo ]
   then
      WD=`pwd`
      ARCHFILE=$ARG
      if [ `echo $ARG | awk '{print substr($1,0,1)}'` != / ]
      then
         ARCHFILE=$WD/$ARG
      fi
      TMPDIR=/tmp/z2l#$$
      mkdir $TMPDIR
      chmod og-rwx $TMPDIR
      cd $TMPDIR
      echo ""
      echo "Reconstructing $ARCHFILE.zoo"
      zoo e// $ARCHFILE.zoo
      \rm $ARCHFILE.zoo
      FILES=`ls -A`
      echo $FILES
      lharc a $ARCHFILE.lzh $FILES
      cd $WD
      \rm -R $TMPDIR
   else
      echo ""; echo "zoo2lzh: $ARG.zoo nonexistent or limited permission"
   fi
done
echo ""
