Fix stat/lstat error checking in a few places.

closes #6929. Please review.
yeah, you're right. sorry, was moving too fast. will be fixed in a minute.