#!/bin/bash

set -e

DIR="pingus"
OUTFILE="install_files.nsh"

echo "# automatically generated by $0" > $OUTFILE

find "$DIR" -type d -printf "%P\0" | \
while read -d $'\0' -r filename; do 
    filename=${filename//\//\\}
    echo "CreateDirectory \"\$INSTDIR\\${filename}\"" >> $OUTFILE
done

find "$DIR" -type f -printf "%P\0" | \
while read -d $'\0' -r filename; do 
    filename=${filename//\//\\}
     echo "File \"/oname=${filename}\" \"pingus\\${filename}\"" >> $OUTFILE
done

##########################################################

OUTFILE="uninstall_files.nsh"

echo "# automatically generated by $0" > $OUTFILE
find "$DIR" -type f -printf "%P\0" | \
while read -d $'\0' -r filename; do 
    filename=${filename//\//\\}
    echo "Delete \"\$INSTDIR\\${filename}\"" >> $OUTFILE
done

find "$DIR" -depth -type d -printf "%P\0" | \
while read -d $'\0' -r filename; do 
    filename=${filename//\//\\}
    echo "RmDir \"\$INSTDIR\\${filename}\"" >> $OUTFILE
done

# EOF #
