comparison libpurple/buddyicon.c @ 21121:35b4f1dc4c8d

replace most calls to strerror with calls to g_strerror. strerror will return a locale-specific string in the locale-specific encoding, which isn't guaranteed to be UTF-8. g_strerror will always return a UTF-8 string. I left gg and zephyr untouched, since gg doesn't include glib headers yet, and zephyr does something weird with a #define for strerror. Someone more familliar with those should take a look. And the win32 guys should check and see if I screwed something up, since they had strerror #defined to something else. This should fix #2247 (and maybe some mystery crashes)
author Nathan Walp <nwalp@pidgin.im>
date Sat, 03 Nov 2007 17:52:28 +0000
parents 4d4eb6831722
children 837c382af6a4
comparison
equal deleted inserted replaced
21120:0cc12e6909e2 21121:35b4f1dc4c8d
114 114
115 if (g_mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0) 115 if (g_mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0)
116 { 116 {
117 purple_debug_error("buddyicon", 117 purple_debug_error("buddyicon",
118 "Unable to create directory %s: %s\n", 118 "Unable to create directory %s: %s\n",
119 dirname, strerror(errno)); 119 dirname, g_strerror(errno));
120 } 120 }
121 } 121 }
122 122
123 if ((file = g_fopen(path, "wb")) != NULL) 123 if ((file = g_fopen(path, "wb")) != NULL)
124 { 124 {
125 if (!fwrite(purple_imgstore_get_data(img), purple_imgstore_get_size(img), 1, file)) 125 if (!fwrite(purple_imgstore_get_data(img), purple_imgstore_get_size(img), 1, file))
126 { 126 {
127 purple_debug_error("buddyicon", "Error writing %s: %s\n", 127 purple_debug_error("buddyicon", "Error writing %s: %s\n",
128 path, strerror(errno)); 128 path, g_strerror(errno));
129 } 129 }
130 else 130 else
131 purple_debug_info("buddyicon", "Wrote cache file: %s\n", path); 131 purple_debug_info("buddyicon", "Wrote cache file: %s\n", path);
132 132
133 fclose(file); 133 fclose(file);
134 } 134 }
135 else 135 else
136 { 136 {
137 purple_debug_error("buddyicon", "Unable to create file %s: %s\n", 137 purple_debug_error("buddyicon", "Unable to create file %s: %s\n",
138 path, strerror(errno)); 138 path, g_strerror(errno));
139 g_free(path); 139 g_free(path);
140 return; 140 return;
141 } 141 }
142 g_free(path); 142 g_free(path);
143 } 143 }
161 if (g_file_test(path, G_FILE_TEST_EXISTS)) 161 if (g_file_test(path, G_FILE_TEST_EXISTS))
162 { 162 {
163 if (g_unlink(path)) 163 if (g_unlink(path))
164 { 164 {
165 purple_debug_error("buddyicon", "Failed to delete %s: %s\n", 165 purple_debug_error("buddyicon", "Failed to delete %s: %s\n",
166 path, strerror(errno)); 166 path, g_strerror(errno));
167 } 167 }
168 else 168 else
169 { 169 {
170 purple_debug_info("buddyicon", "Deleted cache file: %s\n", path); 170 purple_debug_info("buddyicon", "Deleted cache file: %s\n", path);
171 } 171 }
949 if ((file = g_fopen(path, "wb")) != NULL) 949 if ((file = g_fopen(path, "wb")) != NULL)
950 { 950 {
951 if (!fwrite(icon_data, icon_len, 1, file)) 951 if (!fwrite(icon_data, icon_len, 1, file))
952 { 952 {
953 purple_debug_error("buddyicon", "Error writing %s: %s\n", 953 purple_debug_error("buddyicon", "Error writing %s: %s\n",
954 path, strerror(errno)); 954 path, g_strerror(errno));
955 } 955 }
956 else 956 else
957 purple_debug_info("buddyicon", "Wrote migrated cache file: %s\n", path); 957 purple_debug_info("buddyicon", "Wrote migrated cache file: %s\n", path);
958 958
959 fclose(file); 959 fclose(file);
960 } 960 }
961 else 961 else
962 { 962 {
963 purple_debug_error("buddyicon", "Unable to create file %s: %s\n", 963 purple_debug_error("buddyicon", "Unable to create file %s: %s\n",
964 path, strerror(errno)); 964 path, g_strerror(errno));
965 g_free(new_filename); 965 g_free(new_filename);
966 g_free(path); 966 g_free(path);
967 967
968 delete_buddy_icon_settings(node, setting_name); 968 delete_buddy_icon_settings(node, setting_name);
969 return; 969 return;
1054 1054
1055 if (g_mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0) 1055 if (g_mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0)
1056 { 1056 {
1057 purple_debug_error("buddyicon", 1057 purple_debug_error("buddyicon",
1058 "Unable to create directory %s: %s\n", 1058 "Unable to create directory %s: %s\n",
1059 dirname, strerror(errno)); 1059 dirname, g_strerror(errno));
1060 } 1060 }
1061 } 1061 }
1062 } 1062 }
1063 1063
1064 while (node != NULL) 1064 while (node != NULL)