Place symlinks to dirs along with dirs

This commit is contained in:
Arun Prakash Jana 2019-01-29 21:22:28 +05:30
parent ebd278e2cd
commit 725349976a
No known key found for this signature in database
GPG key ID: A75979F35C080412

View file

@ -182,7 +182,7 @@ disabledbg()
#define DESCRIPTOR_LEN 32 #define DESCRIPTOR_LEN 32
#define _ALIGNMENT 0x10 /* 16-byte alignment */ #define _ALIGNMENT 0x10 /* 16-byte alignment */
#define _ALIGNMENT_MASK 0xF #define _ALIGNMENT_MASK 0xF
#define SYMLINK_TO_DIR 0x1 #define DIR_OR_LINK_TO_DIR 0x1
#define HOME_LEN_MAX 64 #define HOME_LEN_MAX 64
#define CTX_MAX 4 #define CTX_MAX 4
#define DOT_FILTER_LEN 7 #define DOT_FILTER_LEN 7
@ -1199,12 +1199,12 @@ static int entrycmp(const void *va, const void *vb)
pa = (pEntry)va; pa = (pEntry)va;
pb = (pEntry)vb; pb = (pEntry)vb;
/* Sort directories first */ if ((pb->flags & DIR_OR_LINK_TO_DIR) != (pa->flags & DIR_OR_LINK_TO_DIR)) {
if (S_ISDIR(pb->mode) && !S_ISDIR(pa->mode)) if (pb->flags & DIR_OR_LINK_TO_DIR)
return 1; return 1;
if (S_ISDIR(pa->mode) && !S_ISDIR(pb->mode))
return -1; return -1;
}
/* Do the actual sorting */ /* Do the actual sorting */
if (cfg.mtimeorder) if (cfg.mtimeorder)
@ -1897,7 +1897,7 @@ static void printent_long(struct entry *ent, int sel, uint namecols)
printw(" %-16.16s / %s/\n", buf, pname); printw(" %-16.16s / %s/\n", buf, pname);
break; break;
case S_IFLNK: case S_IFLNK:
if (ent->flags & SYMLINK_TO_DIR) if (ent->flags & DIR_OR_LINK_TO_DIR)
printw(" %-16.16s @/ %s@\n", buf, pname); printw(" %-16.16s @/ %s@\n", buf, pname);
else else
printw(" %-16.16s @ %s@\n", buf, pname); printw(" %-16.16s @ %s@\n", buf, pname);
@ -2516,13 +2516,18 @@ static int dentfill(char *path, struct entry **dents)
} }
} }
/* Flag if this is a symlink to a dir */ /* Flag if this is a dir or symlink to a dir */
if (S_ISLNK(sb.st_mode)) if (S_ISDIR(sb.st_mode))
dentp->flags |= DIR_OR_LINK_TO_DIR;
else if (!S_ISLNK(sb.st_mode))
dentp->flags &= ~DIR_OR_LINK_TO_DIR;
else {
if (!fstatat(fd, namep, &sb, 0)) { if (!fstatat(fd, namep, &sb, 0)) {
if (S_ISDIR(sb.st_mode)) if (S_ISDIR(sb.st_mode))
dentp->flags |= SYMLINK_TO_DIR; dentp->flags |= DIR_OR_LINK_TO_DIR;
else else
dentp->flags &= ~SYMLINK_TO_DIR; dentp->flags &= ~DIR_OR_LINK_TO_DIR;
}
} }
++n; ++n;