Use stat to check that paths are equivalent

Replaces the previous approach of comparing path as string.
The previous approach didn't work reliable on case insenstive filesystems
or with symlinks.

Change-Id: Iee11c172db89b98a26b3592be2f285110a85a632