]> Sergey Matveev's repositories - nnn.git/commitdiff
Simpler symlink to dir check
authorArun Prakash Jana <engineerarun@gmail.com>
Wed, 27 Feb 2019 13:57:35 +0000 (19:27 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Thu, 28 Feb 2019 17:06:52 +0000 (22:36 +0530)
src/nnn.c

index 20f8cb3f70e7a018b3a25c72097ac8d9997f610b..cbad15e325d0aa30e4f0e3cab01bba21cb7c35de 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -2676,19 +2676,15 @@ static int dentfill(char *path, struct entry **dents)
                }
 
                /* Flag if this is a dir or symlink to a dir */
+               if (S_ISLNK(sb.st_mode)) {
+                       sb.st_mode = 0;
+                       fstatat(fd, namep, &sb, 0);
+               }
+
                if (S_ISDIR(sb.st_mode))
                        dentp->flags |= DIR_OR_LINK_TO_DIR;
-               else if (!S_ISLNK(sb.st_mode)) {
-                       if (dentp->flags & DIR_OR_LINK_TO_DIR)
-                               dentp->flags &= ~DIR_OR_LINK_TO_DIR;
-               } else {
-                       if (!fstatat(fd, namep, &sb, 0)) {
-                               if (S_ISDIR(sb.st_mode))
-                                       dentp->flags |= DIR_OR_LINK_TO_DIR;
-                               else
-                                       dentp->flags &= ~DIR_OR_LINK_TO_DIR;
-                       }
-               }
+               else if (dentp->flags & DIR_OR_LINK_TO_DIR)
+                       dentp->flags &= ~DIR_OR_LINK_TO_DIR;
 
                ++n;
        }