fixed symlink handling
This commit is contained in:
@ -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;
|
||||
|
14
colors.c
14
colors.c
@ -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 */
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user