Check file existence instead of null string

This commit is contained in:
Eizen 2017-01-18 16:58:48 -03:00
parent ce37a46b0f
commit ec7905f50f

View File

@ -191,6 +191,10 @@ static bool have_dynamic_width(void)
return (xctx.geometry.mask & WidthValue && xctx.geometry.w == 0); return (xctx.geometry.mask & WidthValue && xctx.geometry.w == 0);
} }
static bool does_file_exist(const char *filename){
return (access(filename, F_OK) != -1);
}
static bool is_readable_file(const char *filename) static bool is_readable_file(const char *filename)
{ {
return (access(filename, R_OK) != -1); return (access(filename, R_OK) != -1);
@ -342,7 +346,7 @@ static GdkPixbuf *get_pixbuf_from_path(char *icon_path)
current_folder = strndup(start, end - start); current_folder = strndup(start, end - start);
/* try svg */ /* try svg */
maybe_icon_path = g_strconcat(current_folder, "/", icon_path, ".svg", NULL); maybe_icon_path = g_strconcat(current_folder, "/", icon_path, ".svg", NULL);
if (maybe_icon_path == NULL) { if (!does_file_exist(maybe_icon_path)) {
/* fallback to png */ /* fallback to png */
maybe_icon_path = g_strconcat(current_folder, "/", icon_path, ".png", NULL); maybe_icon_path = g_strconcat(current_folder, "/", icon_path, ".png", NULL);
} }