use realpath() function to have this code working when path containes symlinks