Fallback to lstat, if the non-portable dirent.d_type is not available.

Bug-Debian: http://bugs.debian.org/695604
Bug-Ubuntu: https://bugs.launchpad.net/bugs/672643
Fix formatting as per review.