Show permissions in detail mode

This commit is contained in:
Arun Prakash Jana 2019-02-23 19:34:07 +05:30
parent 9bc5171238
commit 1a8df74749
No known key found for this signature in database
GPG Key ID: A75979F35C080412
1 changed files with 20 additions and 14 deletions

View File

@ -1995,9 +1995,15 @@ static void printent(struct entry *ent, int sel, uint namecols)
static void printent_long(struct entry *ent, int sel, uint namecols) static void printent_long(struct entry *ent, int sel, uint namecols)
{ {
static char buf[18], *pname; static char timebuf[18], permbuf[4], *pname;
strftime(buf, 18, "%F %R", localtime(&ent->t)); /* Timestamp */
strftime(timebuf, 18, "%F %R", localtime(&ent->t));
/* Permissions */
snprintf(permbuf, 4, "%d%d%d", (ent->mode >> 6) & 7, (ent->mode >> 3) & 7, ent->mode & 7);
/* Trim escape chars from name */
pname = unescape(ent->name, namecols); pname = unescape(ent->name, namecols);
/* Directories are always shown on top */ /* Directories are always shown on top */
@ -2009,39 +2015,39 @@ static void printent_long(struct entry *ent, int sel, uint namecols)
switch (ent->mode & S_IFMT) { switch (ent->mode & S_IFMT) {
case S_IFREG: case S_IFREG:
if (ent->mode & 0100) if (ent->mode & 0100)
printw(" %-16.16s %8.8s* %s*\n", buf, printw(" %-16.16s 0%s %8.8s* %s*\n", timebuf, permbuf,
coolsize(cfg.blkorder ? ent->blocks << BLK_SHIFT : ent->size), pname); coolsize(cfg.blkorder ? ent->blocks << BLK_SHIFT : ent->size), pname);
else else
printw(" %-16.16s %8.8s %s\n", buf, printw(" %-16.16s 0%s %8.8s %s\n", timebuf, permbuf,
coolsize(cfg.blkorder ? ent->blocks << BLK_SHIFT : ent->size), pname); coolsize(cfg.blkorder ? ent->blocks << BLK_SHIFT : ent->size), pname);
break; break;
case S_IFDIR: case S_IFDIR:
if (cfg.blkorder) if (cfg.blkorder)
printw(" %-16.16s %8.8s/ %s/\n", printw(" %-16.16s 0%s %8.8s/ %s/\n",
buf, coolsize(ent->blocks << BLK_SHIFT), pname); timebuf, permbuf, coolsize(ent->blocks << BLK_SHIFT), pname);
else else
printw(" %-16.16s / %s/\n", buf, pname); printw(" %-16.16s 0%s / %s/\n", timebuf, permbuf, pname);
break; break;
case S_IFLNK: case S_IFLNK:
if (ent->flags & DIR_OR_LINK_TO_DIR) if (ent->flags & DIR_OR_LINK_TO_DIR)
printw(" %-16.16s @/ %s@\n", buf, pname); printw(" %-16.16s 0%s @/ %s@\n", timebuf, permbuf, pname);
else else
printw(" %-16.16s @ %s@\n", buf, pname); printw(" %-16.16s 0%s @ %s@\n", timebuf, permbuf, pname);
break; break;
case S_IFSOCK: case S_IFSOCK:
printw(" %-16.16s = %s=\n", buf, pname); printw(" %-16.16s 0%s = %s=\n", timebuf, permbuf, pname);
break; break;
case S_IFIFO: case S_IFIFO:
printw(" %-16.16s | %s|\n", buf, pname); printw(" %-16.16s 0%s | %s|\n", timebuf, permbuf, pname);
break; break;
case S_IFBLK: case S_IFBLK:
printw(" %-16.16s b %s\n", buf, pname); printw(" %-16.16s 0%s b %s\n", timebuf, permbuf, pname);
break; break;
case S_IFCHR: case S_IFCHR:
printw(" %-16.16s c %s\n", buf, pname); printw(" %-16.16s 0%s c %s\n", timebuf, permbuf, pname);
break; break;
default: default:
printw(" %-16.16s %8.8s? %s?\n", buf, printw(" %-16.16s 0%s %8.8s? %s?\n", timebuf, permbuf,
coolsize(cfg.blkorder ? ent->blocks << BLK_SHIFT : ent->size), pname); coolsize(cfg.blkorder ? ent->blocks << BLK_SHIFT : ent->size), pname);
break; break;
} }