#include "icon.h" #include #include const char * get_file_icon(const char *filename, bool is_dir) { if (is_dir) { return DEFAULT_DIR_ICON; } size_t exact_count = sizeof(exact_match_icons) / sizeof(exact_match_icons[0]); for (size_t i = 0; i < exact_count; i++) { if (strcmp(filename, exact_match_icons[i].key) == 0) { return exact_match_icons[i].icon; } } const char *ext = strrchr(filename, '.'); if (ext && ext != filename) { ext++; // skip "." size_t ext_count = sizeof(ext_icons) / sizeof(ext_icons[0]); for (size_t i = 0; i < ext_count; i++) { if (strcasecmp(ext, ext_icons[i].key) == 0) { return ext_icons[i].icon; } } } return DEFAULT_FILE_ICON; }