Fix stat/lstat error checking in a few places.

closes #6929. Please review.
I believe that `fileInfo` cannot be nil if `err == nil`. Also it can be non-pointer at all.