#!/bin/sh

ASTYLE_CONFIG_FILE=""

function should_style_file {
	file_exts=( '.h' '.c' '.cpp' )
	filename=$(basename "$1")
	extension="${filename##*.}"
	filename="${filename%.*}"

	for i in "${file_exts[@]}"; do
		if [[ $filename == flextGL* ]]; then
			echo "Skipping $1"
			return 1
		fi
		if [[ $filename == Remotery* ]]; then
			echo "Skipping $1"
			return 1
		fi
		if [ ".$extension" == "$i" ]; then
			#echo "$1 is valid"
			return 0
		fi
	done

	return 1
}

function style_files {
	if [ ! -d $1 ]; then
		should_style_file $file
		if [ $? -eq 0 ]; then
			astyle $file --options=${ASTYLE_CONFIG_FILE} -n
		fi
	elif [ -d $1 ]; then
		for file in $1/*; do
			style_files $file
		done
	fi
}

curr_dir=`pwd`
ASTYLE_CONFIG_FILE="$curr_dir/build_scripts/astyle.conf"
tmp="$curr_dir/src"
style_files $tmp

#!/bin/sh

ASTYLE_CONFIG_FILE=""

function should_style_file {
	file_exts=( '.h' '.c' '.cpp' )
	filename=$(basename "$1")
	extension="${filename##*.}"
	filename="${filename%.*}"

	for i in "${file_exts[@]}"; do
		if [ ".$extension" == "$i" ]; then
			#echo "$1 is valid"
			return 0
		fi
	done

	return 1
}

function style_files {
	if [ ! -d $1 ]; then
		should_style_file $file
		if [ $? -eq 0 ]; then
			astyle $file --options=${ASTYLE_CONFIG_FILE} -n
		fi
	elif [ -d $1 ]; then
		if [[ $1 == $curr_dir/src/thirdparty ]]; then
			echo "Skipping $1"
			return 0
		fi
		for file in $1/*; do
			style_files $file
		done
	fi
}

curr_dir=`pwd`
ASTYLE_CONFIG_FILE="$curr_dir/build_scripts/astyle.conf"
tmp="$curr_dir/src"
style_files $tmp

Make styler ignore third party directory.
Make styler ignore third party directory.
