Reimplemented the realpath check.