#! /bin/bash

# usage:
#		untar-official <scintilla_release>
# example:
#		untar-official 140
# produces
#		~/scintilla140
# directory from
#   ~/scintilla140.zip
# official archive with end of line conversions using dos2unix.

version=$1
archive=$HOME/scintilla$version.zip
directory=$HOME/scintilla$version

if [ ! -f $archive ]; then
	echo "The archive $archive doesn't exist."
	exit
fi
if [ -d $directory ]; then
	echo "The directory $directory shouldn't exist. Remove it first."
	exit
fi

mkdir $directory
pushd $directory

unzip $archive

find . -type f ! \( \
		-name '*.png' -o \
		-name '*.ico' -o \
		-name '*.cur' -o \
		-name '*.jpg' -o \
		-name '*.bmp' \) \
	-exec dos2unix -o {} \;

# Moving exported headers to the FXScintilla include directory
mkdir include
mv scintilla/include/Scintilla.h include
mv scintilla/include/SciLexer.h include

popd
