mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 13:51:31 +00:00
Fix mode check
This commit is contained in:
parent
b07becb176
commit
7eb376bcc4
|
@ -343,6 +343,7 @@ The following indicators are used in the detail view:
|
||||||
| `@/` | Symbolic Link to directory |
|
| `@/` | Symbolic Link to directory |
|
||||||
| `b` | Block Device |
|
| `b` | Block Device |
|
||||||
| `c` | Character Device |
|
| `c` | Character Device |
|
||||||
|
| `?` | Unknown |
|
||||||
|
|
||||||
#### Utility dependencies
|
#### Utility dependencies
|
||||||
|
|
||||||
|
|
116
src/nnn.c
116
src/nnn.c
|
@ -1775,16 +1775,30 @@ static char *get_file_sym(mode_t mode)
|
||||||
{
|
{
|
||||||
static char ind[2] = "\0\0";
|
static char ind[2] = "\0\0";
|
||||||
|
|
||||||
if (S_ISDIR(mode))
|
switch (mode & S_IFMT) {
|
||||||
ind[0] = '/';
|
case S_IFREG:
|
||||||
else if (S_ISLNK(mode))
|
if (mode & 0100)
|
||||||
ind[0] = '@';
|
|
||||||
else if (S_ISSOCK(mode))
|
|
||||||
ind[0] = '=';
|
|
||||||
else if (S_ISFIFO(mode))
|
|
||||||
ind[0] = '|';
|
|
||||||
else if (mode & 0100)
|
|
||||||
ind[0] = '*';
|
ind[0] = '*';
|
||||||
|
break;
|
||||||
|
case S_IFDIR:
|
||||||
|
ind[0] = '/';
|
||||||
|
break;
|
||||||
|
case S_IFLNK:
|
||||||
|
ind[0] = '@';
|
||||||
|
break;
|
||||||
|
case S_IFSOCK:
|
||||||
|
ind[0] = '=';
|
||||||
|
break;
|
||||||
|
case S_IFIFO:
|
||||||
|
ind[0] = '|';
|
||||||
|
break;
|
||||||
|
case S_IFBLK: // fallthrough
|
||||||
|
case S_IFCHR:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ind[0] = '?';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return ind;
|
return ind;
|
||||||
}
|
}
|
||||||
|
@ -1814,31 +1828,44 @@ static void printent_long(struct entry *ent, int sel, uint namecols)
|
||||||
if (sel)
|
if (sel)
|
||||||
attron(A_REVERSE);
|
attron(A_REVERSE);
|
||||||
|
|
||||||
if (S_ISDIR(ent->mode)) {
|
switch (ent->mode & S_IFMT) {
|
||||||
|
case S_IFREG:
|
||||||
|
if (ent->mode & 0100)
|
||||||
|
printw(" %-16.16s %8.8s* %s*\n", buf,
|
||||||
|
coolsize(cfg.blkorder ? ent->blocks << BLK_SHIFT : ent->size), pname);
|
||||||
|
else
|
||||||
|
printw(" %-16.16s %8.8s %s\n", buf,
|
||||||
|
coolsize(cfg.blkorder ? ent->blocks << BLK_SHIFT : ent->size), pname);
|
||||||
|
break;
|
||||||
|
case S_IFDIR:
|
||||||
if (cfg.blkorder)
|
if (cfg.blkorder)
|
||||||
printw(" %-16.16s %8.8s/ %s/\n",
|
printw(" %-16.16s %8.8s/ %s/\n",
|
||||||
buf, coolsize(ent->blocks << BLK_SHIFT), pname);
|
buf, coolsize(ent->blocks << BLK_SHIFT), pname);
|
||||||
else
|
else
|
||||||
printw(" %-16.16s / %s/\n", buf, pname);
|
printw(" %-16.16s / %s/\n", buf, pname);
|
||||||
} else if (S_ISLNK(ent->mode)) {
|
break;
|
||||||
|
case S_IFLNK:
|
||||||
if (ent->flags & SYMLINK_TO_DIR)
|
if (ent->flags & SYMLINK_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);
|
||||||
} else if (S_ISSOCK(ent->mode))
|
break;
|
||||||
|
case S_IFSOCK:
|
||||||
printw(" %-16.16s = %s=\n", buf, pname);
|
printw(" %-16.16s = %s=\n", buf, pname);
|
||||||
else if (S_ISFIFO(ent->mode))
|
break;
|
||||||
|
case S_IFIFO:
|
||||||
printw(" %-16.16s | %s|\n", buf, pname);
|
printw(" %-16.16s | %s|\n", buf, pname);
|
||||||
else if (S_ISBLK(ent->mode))
|
break;
|
||||||
|
case S_IFBLK:
|
||||||
printw(" %-16.16s b %s\n", buf, pname);
|
printw(" %-16.16s b %s\n", buf, pname);
|
||||||
else if (S_ISCHR(ent->mode))
|
break;
|
||||||
|
case S_IFCHR:
|
||||||
printw(" %-16.16s c %s\n", buf, pname);
|
printw(" %-16.16s c %s\n", buf, pname);
|
||||||
else if (ent->mode & 0100) {
|
break;
|
||||||
printw(" %-16.16s %8.8s* %s*\n", buf,
|
default:
|
||||||
coolsize(cfg.blkorder ? ent->blocks << BLK_SHIFT : ent->size), pname);
|
printw(" %-16.16s %8.8s? %s?\n", buf,
|
||||||
} else {
|
|
||||||
printw(" %-16.16s %8.8s %s\n", buf,
|
|
||||||
coolsize(cfg.blkorder ? ent->blocks << BLK_SHIFT : ent->size), pname);
|
coolsize(cfg.blkorder ? ent->blocks << BLK_SHIFT : ent->size), pname);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sel)
|
if (sel)
|
||||||
|
@ -1851,46 +1878,43 @@ static char get_fileind(mode_t mode, char *desc)
|
||||||
{
|
{
|
||||||
static char c;
|
static char c;
|
||||||
|
|
||||||
if (S_ISREG(mode)) {
|
switch (mode & S_IFMT) {
|
||||||
|
case S_IFREG:
|
||||||
c = '-';
|
c = '-';
|
||||||
xstrlcpy(desc, "regular file", DESCRIPTOR_LEN);
|
xstrlcpy(desc, "regular file", DESCRIPTOR_LEN);
|
||||||
if (mode & 0100)
|
if (mode & 0100)
|
||||||
/* Length of string "regular file" is 12 */
|
/* Length of string "regular file" is 12 */
|
||||||
xstrlcpy(desc + 12, ", executable", DESCRIPTOR_LEN - 12);
|
xstrlcpy(desc + 12, ", executable", DESCRIPTOR_LEN - 12);
|
||||||
} else if (S_ISDIR(mode)) {
|
break;
|
||||||
|
case S_IFDIR:
|
||||||
c = 'd';
|
c = 'd';
|
||||||
xstrlcpy(desc, "directory", DESCRIPTOR_LEN);
|
xstrlcpy(desc, "directory", DESCRIPTOR_LEN);
|
||||||
} else if (S_ISBLK(mode)) {
|
break;
|
||||||
c = 'b';
|
case S_IFLNK:
|
||||||
xstrlcpy(desc, "block special device", DESCRIPTOR_LEN);
|
|
||||||
} else if (S_ISCHR(mode)) {
|
|
||||||
c = 'c';
|
|
||||||
xstrlcpy(desc, "character special device", DESCRIPTOR_LEN);
|
|
||||||
#ifdef S_ISFIFO
|
|
||||||
} else if (S_ISFIFO(mode)) {
|
|
||||||
c = 'p';
|
|
||||||
xstrlcpy(desc, "FIFO", DESCRIPTOR_LEN);
|
|
||||||
#endif /* S_ISFIFO */
|
|
||||||
#ifdef S_ISLNK
|
|
||||||
} else if (S_ISLNK(mode)) {
|
|
||||||
c = 'l';
|
c = 'l';
|
||||||
xstrlcpy(desc, "symbolic link", DESCRIPTOR_LEN);
|
xstrlcpy(desc, "symbolic link", DESCRIPTOR_LEN);
|
||||||
#endif /* S_ISLNK */
|
break;
|
||||||
#ifdef S_ISSOCK
|
case S_IFSOCK:
|
||||||
} else if (S_ISSOCK(mode)) {
|
|
||||||
c = 's';
|
c = 's';
|
||||||
xstrlcpy(desc, "socket", DESCRIPTOR_LEN);
|
xstrlcpy(desc, "socket", DESCRIPTOR_LEN);
|
||||||
#endif /* S_ISSOCK */
|
break;
|
||||||
#ifdef S_ISDOOR
|
case S_IFIFO:
|
||||||
/* Solaris 2.6, etc. */
|
c = 'p';
|
||||||
} else if (S_ISDOOR(mode)) {
|
xstrlcpy(desc, "FIFO", DESCRIPTOR_LEN);
|
||||||
c = 'D';
|
break;
|
||||||
desc[0] = '\0';
|
case S_IFBLK:
|
||||||
#endif /* S_ISDOOR */
|
c = 'b';
|
||||||
} else {
|
xstrlcpy(desc, "block special device", DESCRIPTOR_LEN);
|
||||||
|
break;
|
||||||
|
case S_IFCHR:
|
||||||
|
c = 'c';
|
||||||
|
xstrlcpy(desc, "character special device", DESCRIPTOR_LEN);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
/* Unknown type -- possibly a regular file? */
|
/* Unknown type -- possibly a regular file? */
|
||||||
c = '?';
|
c = '?';
|
||||||
desc[0] = '\0';
|
desc[0] = '\0';
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
|
|
Loading…
Reference in a new issue