Fix symlink resolution bugs with finding BASE_PATH

We first need to resolve the location of the file, and then find
the directory it is in. This will work all the time.

Change-Id: Ia437364d23aacca49d8678a5c64ff0ec86721954