about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--configure.ac1
-rw-r--r--src/libutil/util.cc4
-rw-r--r--src/libutil/util.hh6
3 files changed, 11 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 88e64573da88..bade079b3b53 100644
--- a/configure.ac
+++ b/configure.ac
@@ -48,6 +48,7 @@ test "$localstatedir" = '${prefix}/var' && localstatedir=/nix/var
 
 
 # Solaris-specific stuff.
+AC_STRUCT_DIRENT_D_TYPE
 if test "$sys_name" = sunos; then
     # Solaris requires -lsocket -lnsl for network functions
     LIBS="-lsocket -lnsl $LIBS"
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 27116fd18297..d1b67c6d4515 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -232,7 +232,11 @@ 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
     }
     if (errno) throw SysError(format("reading directory ‘%1%’") % path);
 
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index 038838820899..2edc5344fdc1 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -11,6 +11,12 @@
 
 #include <cstdio>
 
+#ifndef HAVE_STRUCT_DIRENT_D_TYPE
+#define DT_UNKNOWN 0
+#define DT_REG 1
+#define DT_LNK 2
+#define DT_DIR 3
+#endif
 
 namespace nix {