diff options
author | Arun Prakash Jana <engineerarun@gmail.com> | 2020-01-18 14:58:27 +0530 |
---|---|---|
committer | Arun Prakash Jana <engineerarun@gmail.com> | 2020-01-18 14:58:48 +0530 |
commit | afb7efc860a50d683c8c3df36126b664caff9300 (patch) | |
tree | 0f5ed55e9846321403cadb939b1e2ecb20a5fb02 /src/nnn.c | |
parent | 1dd691d20b53530ab87403686431add2807fd942 (diff) | |
download | nnn-afb7efc860a50d683c8c3df36126b664caff9300.tar.gz |
Merge functions
Diffstat (limited to 'src/nnn.c')
-rw-r--r-- | src/nnn.c | 32 |
1 files changed, 12 insertions, 20 deletions
@@ -2783,47 +2783,39 @@ static char *coolsize(off_t size) return size_buf; } -static char get_fileind(mode_t mode) +/* Convert a mode field into "ls -l" type perms field. */ +static char *get_lsperms(mode_t mode) { - char c = '\0'; + static const char * const rwx[] = {"---", "--x", "-w-", "-wx", "r--", "r-x", "rw-", "rwx"}; + static char bits[11] = {'\0'}; switch (mode & S_IFMT) { case S_IFREG: - c = '-'; + bits[0] = '-'; break; case S_IFDIR: - c = 'd'; + bits[0] = 'd'; break; case S_IFLNK: - c = 'l'; + bits[0] = 'l'; break; case S_IFSOCK: - c = 's'; + bits[0] = 's'; break; case S_IFIFO: - c = 'p'; + bits[0] = 'p'; break; case S_IFBLK: - c = 'b'; + bits[0] = 'b'; break; case S_IFCHR: - c = 'c'; + bits[0] = 'c'; break; default: - c = '?'; + bits[0] = '?'; break; } - return c; -} - -/* Convert a mode field into "ls -l" type perms field. */ -static char *get_lsperms(mode_t mode) -{ - static const char * const rwx[] = {"---", "--x", "-w-", "-wx", "r--", "r-x", "rw-", "rwx"}; - static char bits[11] = {'\0'}; - - bits[0] = get_fileind(mode); xstrlcpy(&bits[1], rwx[(mode >> 6) & 7], 4); xstrlcpy(&bits[4], rwx[(mode >> 3) & 7], 4); xstrlcpy(&bits[7], rwx[(mode & 7)], 4); |