La funzione realpath() forse può essere utile?