Fix stat/lstat error checking in a few places.

closes #6929. Please review.
I'm wondering if you could somehow merge this `Lstat(filepath)` with the `Stat(filepath)` 4 lines above. I don't think we need both.