changeset 24584:2b705f7b3cbf

merge of 'eb82ee09b8fde4b12b5de352686970ccc82a3db6' and 'f659186b896d5b905b4cf31a38eab4638224ca0f'
author Marcus Lundblad <ml@update.uu.se>
date Tue, 02 Dec 2008 18:48:54 +0000
parents fce52fff8496 (current diff) c31be282935d (diff)
children fb5a11ec8be6 95ef7beb926b 6f94b4a27372 21b21bffd946 0285bb19f311
files
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtksmiley.c	Tue Dec 02 18:22:35 2008 +0000
+++ b/pidgin/gtksmiley.c	Tue Dec 02 18:48:54 2008 +0000
@@ -272,11 +272,25 @@
 			gchar *buffer = NULL;
 			gsize size = 0;
 			gchar *filename;
+			const gchar *dirname = purple_smileys_get_storing_dir();
+			
+			/* since this may be called before purple_smiley_new_* has ever been
+			 called, we create the storing dir, if it doesn't exist yet, to be
+			 able to save the pixbuf before adding the smiley */
+			if (!g_file_test(dirname, G_FILE_TEST_IS_DIR)) {
+				purple_debug_info("gtksmiley", "Creating smileys directory.\n");
 
+				if (g_mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0) {
+					purple_debug_error("gtksmiley",
+			                   "Unable to create directory %s: %s\n",
+			                   dirname, g_strerror(errno));
+				}
+			}
+			
 			gdk_pixbuf_save_to_buffer(s->custom_pixbuf, &buffer, &size,
 				"png", NULL, "compression", "9", NULL, NULL);
 			filename = purple_util_get_image_filename(buffer, size);
-			s->filename = g_build_filename(purple_smileys_get_storing_dir(), filename, NULL);
+			s->filename = g_build_filename(dirname, filename, NULL);
 			purple_util_write_data_to_file_absolute(s->filename, buffer, size);
 			g_free(filename);
 			g_free(buffer);