#!/bin/ksh
# script for copying IMAGES, ADDONS, and SOUNDS from
# wwwfoil directories: <seporgimagedir>, <addon>, <audio.ra>
#
# script writes to current directory  files with changed names:
# ../seporgimagedir/NNN.gif => sldNNN.gif
# ../addon/foilN.addoninfo =>  sldNNN.adi
# ../audio.ra/foilN.rainfo =>  sldNNN.rai
# ../audio.ra/foilN.ra =>      sldNNN.ra
#
# in addition, the script copies to the <out_dir> directory
# concatenated files: extrainfo and processed
# as file course.gcf
#

EXTRA=../extrainfo
PROCESS=../processed
PERS=../perstemp
OPTIONS=../options
PERSWWW=../perswww
SCRIPTDIR=..
OUT_GCF=course.gcf
SEP_DIR=../seporgimagedir
GIF_DIR=../seporggifdir
ADD_DIR=../addon
AUD_DIR=../audio.ra
CP="ln -s -f"
DISPLAY=true
#DISPLAY non empty means than file names are displayed

#echo "Copying audio/images/sounds from GCF directories to current directory  v. 1.02."
#echo ""
CURRENT=`pwd`

  #echo "Copying files to `pwd` directory."
  if [ -d ${SEP_DIR} ]
  then
    echo -n ""
  else
    if [ -d ${GIF_DIR} ]
    then
      SEP_DIR=${GIF_DIR}
    fi
  fi
  if [ -d ${SEP_DIR} ]
  then
    echo "    Copying images from <${SEP_DIR}> directory."
    cd ${SEP_DIR}
    FILES=`ls ???.gif ???.gif ???.jpg ???.JPG 2> /dev/null`
    cd ${CURRENT} 
    for i in ${FILES}
    do
      if [ -z "${DISPLAY}" ]
      then
        echo "    Copying <${SEP_DIR}/${i}> to <img${i}>."
      fi
      ${CP} ${SEP_DIR}/${i} img${i}
    done
    if [ -r ${SEP_DIR}/abstract.gif ]
    then 	
      if [ -z "${DISPLAY}" ]
      then
        echo "    Copying <${SEP_DIR}/abstract.gif> to img000.gif>"
      fi
      ${CP} ${SEP_DIR}/abstract.gif img000.gif
    fi
    if [ -r ${SEP_DIR}/abstract.GIF ]
    then   
      if [ -z "${DISPLAY}" ]
      then
        echo "    Copying <${SEP_DIR}/abstract.GIF> to img000.gif>"
      fi
      ${CP} ${SEP_DIR}/abstract.GIF img000.gif
    fi
    if [ -r ${SEP_DIR}/abstract.jpg ]
    then 
      if [ -z "${DISPLAY}" ]
      then
        echo "    Copying <${SEP_DIR}/abstract.jpg> to img000.jpg>"
      fi
      ${CP} ${SEP_DIR}/abstract.jpg img000.jpg
    fi
    if [ -r ${SEP_DIR}/abstract.JPG ]
    then
      if [ -z "${DISPLAY}" ]
      then
        echo "    Copying <${SEP_DIR}/abstract.JPG> to img000.jpg>"
      fi
      ${CP} ${SEP_DIR}/abstract.JPG img000.jpg
    fi
  else
    echo "    Warning: directory <${SEP_DIR}> does not exist, no files were copied."
  fi
  if [ -d ${ADD_DIR} ]
  then
    echo "    Copying addon information from <${ADD_DIR}> directory."
    cd ${ADD_DIR}
    FILES=`ls foil*.addoninfo 2> /dev/null`
    cd ${CURRENT} 
    for i in ${FILES}
    do
      if [ -z "${DISPLAY}" ]
      then
      echo "    Copying <${ADD_DIR}/${i}> to <`change_name ${i} adi`>."
      fi
      ${CP} ${ADD_DIR}/${i} `change_name ${i} adi`
    done
  else
    echo "    Warning: directory <${ADD_DIR}> does not exist, no files were copied."
  fi
  if [ -d ${AUD_DIR} ]
  then
    echo "    Copying sound information from <${AUD_DIR}> directory."
    cd ${AUD_DIR}
    FILES=`ls foil*.rainfo 2>/dev/null`
    cd ${CURRENT} 
    for i in ${FILES}
    do
      if [ -z "${DISPLAY}" ]
      then
      echo "    Copying <${AUD_DIR}/${i}> to <`change_name ${i} rai`>."
      fi
      ${CP} ${AUD_DIR}/${i} `change_name ${i} rai`
    done
    echo "    Copying sounds from <${AUD_DIR}> directory."
    cd ${AUD_DIR}
    FILES=`ls foil*.ra 2>/dev/null`
    cd ${CURRENT} 
    for i in ${FILES}
    do
      if [ -z "${DISPLAY}" ]
      then
       echo "    Copying <${AUD_DIR}/${i}> to <`change_name ${i} ra`>."
      fi
      ${CP} ${AUD_DIR}/${i} `change_name ${i} ra`
    done
  else
    echo "    Warning: directory <${AUD_DIR}> does not exist, no files were copied."
  fi
  rm -f ${OUT_GCF}
  if [ -r ${EXTRA} ]
  then
    echo "    Copying <${EXTRA}> file."
    ${CP} ${EXTRA} . 
  else
    echo "    File <${EXTRA}> not found."
  fi
  if [ -r ${OPTIONS} ]
  then
    echo "    Copying <${OPTIONS}> file."
    ${CP} ${OPTIONS} .
  else
    echo "    File <${OPTIONS}> not found."
  fi
  echo "    Copying all <scripts> from ${SCRIPTDIR} directory."
  ${CP} ${SCRIPTDIR}/*script* .
 if [ -r ${PERSWWW} ]
  then
    echo "    Copying <${PERSWWW}> file."
    ${CP} ${PERSWWW} . 
  else
    echo "    File <${PERSWWW}> not found."
  fi


