aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-02-27 19:27:35 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-02-28 22:36:52 +0530
commit26861532a24d32405546d9734936c0f684db9b33 (patch)
tree2403ad2f2eb8bd671f73e9cad82590c35537a29e
parent005c94d1ba7b2f5196843f54e4c8001e97459127 (diff)
downloadnnn-26861532a24d32405546d9734936c0f684db9b33.tar.gz
Simpler symlink to dir check
-rw-r--r--src/nnn.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 20f8cb3..cbad15e 100644
--- 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;
}