Use DT_UNKNOWN when dirent d_type extension is not supported.

edolstra:
“…since callers of readDirectory have to handle the possibility of
 DT_UNKNOWN anyway, and we don't want to do a stat call for every
 directory entry unless it's really needed.”
This commit is contained in:
Danny Wilson 2015-11-25 21:57:19 +01:00
parent cdb346c65e
commit 69b9d8fdbd

View file

@ -232,11 +232,7 @@ DirEntries readDirectory(const Path & path)
checkInterrupt();
string name = dirent->d_name;
if (name == "." || name == "..") continue;
#ifdef HAVE_STRUCT_DIRENT_D_TYPE
entries.emplace_back(name, dirent->d_ino, dirent->d_type);
#else
entries.emplace_back(name, dirent->d_ino, getFileType(absPath(name, path)));
#endif
entries.emplace_back(name, dirent->d_ino, #ifdef HAVE_STRUCT_DIRENT_D_TYPE dirent->d_type #else DT_UNKNOWN #endif);
}
if (errno) throw SysError(format("reading directory %1%") % path);