* src/mimeview.c
[claws.git] / src / mimeview.c
index 8a52beea78b38f4b2c2c144380bf8e11dcca26ff..b26273e518c4082b6a31f2f58d4c1185e1fd576d 100644 (file)
@@ -427,9 +427,9 @@ static GtkCTreeNode *mimeview_append_part(MimeView *mimeview,
        gchar *str[N_MIMEVIEW_COLS];
 
        if (partinfo->type != MIMETYPE_UNKNOWN && partinfo->subtype) {
-               snprintf(content_type, 64, "%s/%s", procmime_get_type_str(partinfo->type), partinfo->subtype);
+               g_snprintf(content_type, 64, "%s/%s", procmime_get_type_str(partinfo->type), partinfo->subtype);
        } else {
-               snprintf(content_type, 64, "UNKNOWN");
+               g_snprintf(content_type, 64, "UNKNOWN");
        }
 
        str[COL_MIMETYPE] = content_type;
@@ -873,6 +873,24 @@ static void mimeview_save_all(MimeView *mimeview)
        dirname = filesel_select_file(_("Save as"), defname);
        if (!dirname) return;
 
+       if (!is_dir_exist (dirname)) {
+               alertpanel_error(_("`%s' is not a directory."),
+                                dirname);
+               g_free (dirname);
+               return;
+       }
+       
+       { /* add a / after the dirname, in case the user didn't */
+               gchar *dirname_tmp = NULL;
+               int dirname_last_char = strlen (dirname) - 1;
+
+               if (dirname[dirname_last_char] != G_DIR_SEPARATOR) {
+                       dirname_tmp = g_strconcat (dirname, G_DIR_SEPARATOR_S, NULL);
+                       g_free (dirname);
+                       dirname = dirname_tmp;
+               }
+       }
+
        /* return to first children */
        if (!partinfo->parent->children) return;  /* multipart container? */
        attachment = partinfo->parent->children->next;