file: increase icon to 8 bytes; add icon size range checks
This commit is contained in:
parent
098403eba6
commit
2170c3dbf2
2 changed files with 11 additions and 8 deletions
17
ccc.c
17
ccc.c
|
@ -414,8 +414,8 @@ void add_file_stat(char *filename, char *path, int ftype)
|
||||||
arraylist_add(files, filename, path, NULL, REG, NULL, DEF_COLOR, 0, 0);
|
arraylist_add(files, filename, path, NULL, REG, NULL, DEF_COLOR, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int type;
|
int type = 0;
|
||||||
char icon_str[5];
|
char icon_str[8] = {0};
|
||||||
|
|
||||||
filename[strlen(filename)] = '\0';
|
filename[strlen(filename)] = '\0';
|
||||||
/* handle file without extension
|
/* handle file without extension
|
||||||
|
@ -427,17 +427,20 @@ void add_file_stat(char *filename, char *path, int ftype)
|
||||||
}
|
}
|
||||||
/* add file extension */
|
/* add file extension */
|
||||||
icon *ext_icon = hashtable_search(ext ? ext : filename);
|
icon *ext_icon = hashtable_search(ext ? ext : filename);
|
||||||
if (!ext_icon)
|
if (!ext_icon) {
|
||||||
memcpy(icon_str, "", 4);
|
char ch[] = "";
|
||||||
else
|
memcpy(icon_str, ch, sizeof(ch));
|
||||||
memcpy(icon_str, ext_icon->icon, 4);
|
} else {
|
||||||
|
strncpy(icon_str, ext_icon->icon, sizeof(icon_str));
|
||||||
|
}
|
||||||
|
|
||||||
int color = DEF_COLOR;
|
int color = DEF_COLOR;
|
||||||
|
|
||||||
if (S_ISDIR(file_stat.st_mode)) {
|
if (S_ISDIR(file_stat.st_mode)) {
|
||||||
type = DRY; /* dir */
|
type = DRY; /* dir */
|
||||||
color = DIR_COLOR;
|
color = DIR_COLOR;
|
||||||
memcpy(icon_str, "", 4);
|
char ch[] = "";
|
||||||
|
memcpy(icon_str, ch, sizeof(ch));
|
||||||
} else if (S_ISREG(file_stat.st_mode)) {
|
} else if (S_ISREG(file_stat.st_mode)) {
|
||||||
type = REG; /* regular file */
|
type = REG; /* regular file */
|
||||||
color = REG_COLOR;
|
color = REG_COLOR;
|
||||||
|
|
2
file.h
2
file.h
|
@ -19,7 +19,7 @@ typedef struct {
|
||||||
int type;
|
int type;
|
||||||
char *stats;
|
char *stats;
|
||||||
int color;
|
int color;
|
||||||
char icon[5];
|
char icon[8];
|
||||||
} file;
|
} file;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
Loading…
Reference in a new issue