about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDanny Wilson <danny@prime.vc>2015-11-25T20·57+0100
committerDanny Wilson <danny@prime.vc>2015-11-25T20·57+0100
commit69b9d8fdbd4d428515c15cf47c2ed2324f7aa021 (patch)
treef910ec3a1d82d9c9d6b659130e3a9c8d171f50d8
parentcdb346c65eeb9f976cf3db21b3cb2f7d8837cf6b (diff)
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.”
-rw-r--r--src/libutil/util.cc6
1 files changed, 1 insertions, 5 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index d1b67c6d4515..656d67a53b8d 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -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);