handle other file type

This commit is contained in:
Night Kaly 2024-03-13 18:28:04 +00:00
parent a4161aff04
commit 4dcfda0167
No known key found for this signature in database
GPG key ID: 8E829D3381CFEBBE

11
ccc.c
View file

@ -340,7 +340,16 @@ long add_file_stat(char *filepath)
strcpy(type, "REG"); /* regular file */ strcpy(type, "REG"); /* regular file */
} else if (S_ISLNK(file_stat.st_mode)) { } else if (S_ISLNK(file_stat.st_mode)) {
strcpy(type, "LNK"); /* symbolic link */ 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)); char *total_stat = memalloc(45 * sizeof(char));
snprintf(total_stat, 45, "%-18s %-10s", time, size); snprintf(total_stat, 45, "%-18s %-10s", time, size);