From 4dcfda0167bd7e7d3fbfd07cd0cc64776524d301 Mon Sep 17 00:00:00 2001 From: night0721 Date: Wed, 13 Mar 2024 18:28:04 +0000 Subject: [PATCH] handle other file type --- ccc.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ccc.c b/ccc.c index bcd1bc5..3de382e 100644 --- a/ccc.c +++ b/ccc.c @@ -340,7 +340,16 @@ long add_file_stat(char *filepath) strcpy(type, "REG"); /* regular file */ } else if (S_ISLNK(file_stat.st_mode)) { strcpy(type, "LNK"); /* symbolic link */ - } // socket, block device, character device and FIFO not yet implemented + } else if (S_ISCHR(file_stat.st_mode)) { + strcpy(type, "CHR"); /* character device */ + } else if (S_ISSOCK(file_stat.st_mode)) { + strcpy(type, "SOC"); /* socket */ + } else if (S_ISBLK(file_stat.st_mode)) { + strcpy(type, "BLK"); /* block device */ + } else if (S_ISFIFO(file_stat.st_mode)) { + strcpy(type, "FIF"); /* FIFO */ + } + /* don't know how to handle socket, block device, character device and FIFO */ char *total_stat = memalloc(45 * sizeof(char)); snprintf(total_stat, 45, "%-18s %-10s", time, size);