#!/bin/zsh

project_name="Lynar Studios - Standard Library"

script_directory="$PWD"
root_directory=$(dirname $(dirname $script_directory))
test_directory="$root_directory/test"
test_resources_directory="$test_directory/resources"
test_file_name="no-writable.txt"
test_file_path="$test_resources_directory/$test_file_name"

indentation="  -->"
error_level="[ERROR]"

########################################
# script execution
########################################

echo "Setting up project '$project_name' for development on MacOS environment ...
"

# check if rights are sufficient

echo "$indentation checking rights ..."

if ! sudo -v; then
  echo "$indentation $error_level no sufficient rights, must be executed as sudo-user ..."
else
  echo "$indentation user is sudo ..."
fi

# list variables

echo "$indentation script directory identified as '$script_directory' ..."
echo "$indentation root directory identified as '$root_directory' ..."
echo "$indentation test directory identified as '$test_directory' ..."
echo "$indentation test resources directory identified as '$test_resources_directory' ..."

# prepare test files

if sudo -v; then
  echo "$indentation changing permissions for '$test_file_path' file ..."
  chmod -w "$test_file_path"
fi