diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-01-05T12·49+0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-01-05T12·49+0100 |
commit | 6298afc0478222eb0d5e57eaafe46965a1df7ca3 (patch) | |
tree | c789fe66b6f4a1363bd23316f9a0b1a3d3266342 | |
parent | 36b9ce24b11a87b3e71f4f4fec9f3e5ad6af7b95 (diff) | |
parent | 69b9d8fdbd4d428515c15cf47c2ed2324f7aa021 (diff) |
Merge pull request #685 from vizanto/master
POSIX compliant directory access (fixes build on Solaris)
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | src/libutil/util.cc | 2 | ||||
-rw-r--r-- | src/libutil/util.hh | 6 |
3 files changed, 8 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index df92950ff0cc..3a24053bb6a1 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 75032bf90d0b..c1585e27ea1f 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -232,7 +232,7 @@ DirEntries readDirectory(const Path & path) checkInterrupt(); string name = dirent->d_name; if (name == "." || name == "..") continue; - entries.emplace_back(name, dirent->d_ino, dirent->d_type); + 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); diff --git a/src/libutil/util.hh b/src/libutil/util.hh index f4026a0a884b..cf93c6378a06 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 { |