#!/bin/ksh
######################################################################################
#
#      This script copies all the files from the source directory given by
#      Commandline argument 1 to destination directory given by commandline argument 2.
#      Unneccessary files will be filtered and copied. This script also does the
#      the directory renaming and file renaming  which are required for package
#      renaming.
#
#####################################################################################
cwdir=`pwd`

# Source Directory from which the files have to be copied
# This is usually the uptodate workspace
srcDir=$1

# Destination Directory where the files have to be copied
destDir=$2

echo "[Copy All Files ]srcDir => ${srcDir}"
echo "destDir=> ${destDir}"

# Filter All the deleted files, *.exe files etc.,
cd $srcDir
files=`find . -type d \( -name obj -o -name obj_g -o -name SCCS -o -name CClassHeaders -o -name Codemgr_wsdata -o -name deleted_files \) -prune -o -type f \( -name "*.exe" -o -name "*.obj" -o -name "*.map" -o -name "*.pdb" \) -prune -o \( -type f -o -type l \) -name "*" -print`
if [ ! -z '$files' ]
then
	for i in $files
	do
		dir=`dirname $i`
		# First Check whether the destination directory exists for
		# the file and then copy the file
		# If the destination directory doesn't exist then create 
		# it under the destDirectory
		if [ ! -d $destDir/$dir ]
		then
			echo "************************************************"
			echo "Creating dir $destDir/$dir"
			echo "************************************************"
			mkdir -p $destDir/$dir
		fi
		echo "Creating file $destDir/$i"
		cp -f $i $destDir/$i
done
fi

cd $destDir
## xerces structure and file move
#cd $destDir/xml-xerces/java/src/org/apache/xerces

#cd src
#echo "Creating directry com/sun/xml/stream"
#mkdir -p com/sun/xml/stream
mv org/apache/xerces com/sun/xml/stream/
echo "Moved all the sources under org/apache/xerces/ to com/sun/xml/stream"

#mkdir -p com/sun/xml/stream/xerces/impl/io/msg

#mkdir -p com/sun/xml/stream/xerces/parsers
#mkdir -p com/sun/xml/stream/xerces/util


#cd com/sun/org/apache/xerces
#echo "Creating file xerces/internal"
#mkdir -p internal
#mv  * internal

#cd $destDir/xml-xerces/java/src/org/apache/html
#cd ../html

#cd xml-xerces/java/src/org/apache/html
#echo "Creating file html/internal"
#mkdir -p internal
#mv  * internal

#cd $destDir/xml-xerces/java/src/org/apache/wml
#cd ../wml
#cd xml-xerces/java/src/org/apache/wml
#echo "Creating file wml/internal"
#mkdir -p internal
#mv  * internal

#cd $destDir/xml-xerces/java/src/org/apache/xml
#cd xml-xerces/java/src/org/apache/xml

#cd ../xml
#echo "Creating file xml/internal"
#mkdir -p internal
#mv  * internal

cd $cwdir
