fixed symlink handling

This commit is contained in:
nova
2025-07-08 01:57:58 +02:00
parent 4c958dc10a
commit 7fcd148dfe
3 changed files with 14 additions and 14 deletions

View File

@ -86,6 +86,10 @@ void get_dir_content(char *path, unsigned long *dir_file_count, file *dir_conten
dir_content[i].file_type = FILE_TYPE_DIR;
dir_content[i].color_pair = COLOR_DIR;
dir_content[i].file_size = get_dir_size(full_path);
} else if (S_ISLNK(file->st_mode)) {
dir_content[i].file_type = FILE_TYPE_SYMLINK;
dir_content[i].color_pair = COLOR_SYMLINK;
dir_content[i].file_size = get_dir_size(full_path);
} else if (file->st_mode & S_IXUSR) {
dir_content[i].file_type = FILE_TYPE_EXEC;
dir_content[i].color_pair = COLOR_EXEC;
@ -94,10 +98,6 @@ void get_dir_content(char *path, unsigned long *dir_file_count, file *dir_conten
dir_content[i].color_pair = COLOR_BLOCK;
} else if (S_ISCHR(file->st_mode)) {
dir_content[i].file_type = COLOR_CHARDEV;
} else if (S_ISLNK(file->st_mode)) {
dir_content[i].file_type = FILE_TYPE_SYMLINK;
dir_content[i].color_pair = COLOR_SYMLINK;
dir_content[i].file_size = get_dir_size(full_path);
} else if (S_ISFIFO(file->st_mode)) {
dir_content[i].file_type = FILE_TYPE_FIFO;
dir_content[i].color_pair = COLOR_FIFO;

View File

@ -68,15 +68,15 @@ void colors_init() {
} else if (!strcmp(token, "DIR")) {
parse_colors(line, &fg, &bg);
init_pair(1, fg, bg); /* directory */
} else if (!strcmp(token, "EXEC")){
parse_colors(line, &fg, &bg);
init_pair(2, fg, bg); /* exec */
} else if (!strcmp(token, "RESET")){
parse_colors(line, &fg, &bg);
init_pair(3, fg, bg); /* regular file */
} else if (!strcmp(token, "LINK")){
parse_colors(line, &fg, &bg);
init_pair(4, fg, bg); /* symlink */
init_pair(2, fg, bg); /* symlink */
} else if (!strcmp(token, "EXEC")){
parse_colors(line, &fg, &bg);
init_pair(3, fg, bg); /* exec */
} else if (!strcmp(token, "RESET")){
parse_colors(line, &fg, &bg);
init_pair(4, fg, bg); /* regular file */
} else if (!strcmp(token, "BLK")){
parse_colors(line, &fg, &bg);
init_pair(5, fg, bg); /* block device */

View File

@ -28,9 +28,9 @@
#define COLOR_UNKNOWN 0
#define COLOR_DIR 1
#define COLOR_EXEC 2 /* not really a filetype, moreso if it is executable */
#define COLOR_REGULAR 3
#define COLOR_SYMLINK 4
#define COLOR_SYMLINK 2
#define COLOR_EXEC 3 /* not really a filetype, moreso if it is executable */
#define COLOR_REGULAR 4
#define COLOR_BLOCK 5
#define COLOR_CHARDEV 6
#define COLOR_SOCK 7