no need to do a stat then an lstat. lstat will tell us if normal files don't exist.
authorChris Lattner <sabre@nondot.org>
Fri, 7 Jul 2006 21:21:06 +0000 (21:21 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 7 Jul 2006 21:21:06 +0000 (21:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29068 91177308-0d34-0410-b5e6-96231b3b80d8

lib/System/Unix/Path.inc

index 2da76e8ad133427fe27d8a9c7945b6c4e537a5c4..4ca4753962fc54a91cfdd06fd751df03135a958e 100644 (file)
@@ -453,14 +453,11 @@ Path::getDirectoryContents(std::set<Path>& result) const {
   for ( ; de != 0; de = ::readdir(direntries)) {
     if (de->d_name[0] != '.') {
       Path aPath(dirPath + (const char*)de->d_name);
-      struct stat buf;
-      if (0 != stat(aPath.path.c_str(), &buf)) {
-        int stat_errno = errno;
-        struct stat st;
-        if (0 == lstat(aPath.path.c_str(), &st) && S_ISLNK(st.st_mode))
+      struct stat st;
+      if (0 != lstat(aPath.path.c_str(), &st)) {
+        if (S_ISLNK(st.st_mode))
           continue; // dangling symlink -- ignore
-        ThrowErrno(aPath.path + 
-          ": can't determine file object type", stat_errno);
+        ThrowErrno(aPath.path +  ": can't determine file object type");
       }
       result.insert(aPath);
     }