#!/bin/sh

# Note: in order to be able to use the emulator, you need a writable copy of the files within the wins(cw) directory

if [ $# -lt 2 ]; then
	echo "makelinkdir <source> <dest>"
	exit 1
fi

SOURCE=$1
DEST=$2

if [ "`echo $DEST | grep ^/`" = "" ] || [ "`echo $SOURCE | grep ^/`" = "" ]; then
	echo "The source and destination must be a absolute paths!"
	exit 2
fi

cd $SOURCE
mkdir -p $DEST

find . -mindepth 1 -type d -exec mkdir $DEST/{} \;
find . -mindepth 1 -type f -exec ln -s $SOURCE/{} $DEST/{} \;
find . -mindepth 1 -type l -exec ln -s $SOURCE/{} $DEST/{} \;

#find . -mindepth 1 -type d -print0 | sed "s/\\([^\0]\\)\\.\\//\\1/g" | xargs -0r -i echo mkdir $DEST/{}
#find . -mindepth 1 -type f -print0 | sed "s/\\([^\0]\\)\\.\\//\\1/g" | xargs -0r -i echo ln -s $SOURCE/{} $DEST/{}

#for i in `find . -mindepth 1 | sed "s/^\\.\\///"`; do
#	if [ -d $i ]; then
#		mkdir $DEST/$i
#	else
#		ln -s $SOURCE/$i $DEST/$i
#	fi
#done


