Mercurial > pidgin.yaz
changeset 16384:54ea8863b8e8
Switch to using g_file_get_contents() instead of our own code.
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Tue, 24 Apr 2007 19:58:14 +0000 |
parents | 05033ae856b2 |
children | a0df0eb75e1b |
files | libpurple/buddyicon.c |
diffstat | 1 files changed, 8 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/buddyicon.c Tue Apr 24 19:12:48 2007 +0000 +++ b/libpurple/buddyicon.c Tue Apr 24 19:58:14 2007 +0000 @@ -491,33 +491,18 @@ static gboolean read_icon_file(const char *path, guchar **data, size_t *len) { - struct stat st; + GError *err = NULL; - if (!g_stat(path, &st)) + if (!g_file_get_contents(path, data, len, &err)) { - FILE *f = g_fopen(path, "rb"); - if (f) - { - *data = g_malloc(st.st_size); - if (!fread(*data, st.st_size, 1, f)) - { - purple_debug_error("buddyicon", "Error reading %s: %s\n", - path, strerror(errno)); - g_free(*data); - return FALSE; - } - fclose(f); + purple_debug_error("buddyicon", "Error reading %s: %s\n", + path, err->message); + g_error_free(err); - *len = st.st_size; - return TRUE; - } - else - { - purple_debug_error("buddyicon", "Unable to open file %s for reading: %s\n", - path, strerror(errno)); - } + return FALSE; } - return FALSE; + + return TRUE; } PurpleBuddyIcon *