From dde9c776733b7b75338b81531cde03999283c1f0 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 7 Aug 2017 21:34:53 +0100 Subject: [PATCH] Fix FileExists in Utils.cpp Testing for st.st_mode & S_IFLNK doesn't work on OSX, because IFLNK and IFREG share bits, so regular files have a nonzero result and appear to be links. It seems safer and more readable to use the mode test macros, e.g. S_ISLNK and S_ISDIR. --- lib/common/Utils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/common/Utils.cpp b/lib/common/Utils.cpp index dbb422e95..e851a1bd5 100644 --- a/lib/common/Utils.cpp +++ b/lib/common/Utils.cpp @@ -346,9 +346,9 @@ bool FileExists(const std::string& rFilename, int64_t *pFileSize, } // is it a file? - if((st.st_mode & S_IFDIR) == 0) + if(!S_ISDIR(st.st_mode)) { - if(TreatLinksAsNotExisting && ((st.st_mode & S_IFLNK) != 0)) + if(TreatLinksAsNotExisting && S_ISLNK(st.st_mode)) { return false; }