Re: new pre-release: 20040808

hmm, patch was stripped, TAKE 2!

attached is a patch to cpbar.c
run;
        patch -Np1 -i cpbar-1.patch
while in the main source directory, (where the Makefile is)
and also where to put the patch

mvbar will have the same bug

i also cleaned up the const_list casts a bit

fwiw
David Jensen

--- emelfm2-20040808.orig/plugins/cpbar.c       2004-08-08 14:29:01.574866304 
-0500
+++ emelfm2-20040808/plugins/cpbar.c    2004-08-08 14:25:35.785151096 -0500
@@ -333,14 +333,14 @@
        {
                i += 1;
                g_snprintf(dest, sizeof(dest), "%s/%s", dest_dir,
-                               ((FileInfo *)const_list->data)->filename);
+                               (gchar *) const_list->data);
                g_snprintf(src, sizeof(src), "%s/%s", src_dir,
-                               ((FileInfo *)const_list->data)->filename);
+                               (gchar *) const_list->data);
                g_snprintf(command, sizeof(command), "cp -rf \"%s\" \"%s\"", 
src, dest);
                progbarstruct.currname = dest;
 
                
-               if (check && (access(dest, F_OK) == 0))
+               if (access(dest, F_OK) == 0)
                {
                        if ((s = strrchr(dest, '/')) != NULL)
                                s++;
@@ -349,34 +349,41 @@
 
                        gchar *utf = _STR2UTF (s);
                        
-                       gchar dialog_text[MAX_LEN];
-                       g_snprintf (dialog_text, sizeof (dialog_text),
-                               "are you sure you want to overwrite 
<b><u>%s</u></b>?", utf);
-                       GtkWidget *dialog;
-                       dialog = create_confirm_dialog (dialog_text,
-                               (E2_BUTTON_CANCEL | E2_BUTTON_NO |
-                                E2_BUTTON_YES_TO_ALL | E2_BUTTON_YES));
-                       gint result = gtk_dialog_run (GTK_DIALOG (dialog));
-                       g_free (utf);
-                       gtk_widget_destroy (dialog);
-
-                       switch (result)
+                       struct stat statbuf;
+                       if (check  && (0 == lstat(dest, &statbuf))) // exists
                        {
-                               case 111:
-                                       //apply is yes to all
-                                       check = FALSE;
-                               case GTK_RESPONSE_YES:
-                                       progbarstruct.process_id = 
exec_and_capture_output_threaded_progbar(command);   
-                                       gtk_widget_show(window);
-                               case GTK_RESPONSE_NO:
-                               default:
-                                       //CANCEL
+                               if (S_ISDIR(statbuf.st_mode))
+                                       g_snprintf(command, sizeof(command),
+                                                       "cp -rf \"%s\" \"%s\"", 
src, dest_dir);
+                               gchar dialog_text[MAX_LEN];
+                               g_snprintf (dialog_text, sizeof (dialog_text),
+                                       "are you sure you want to overwrite 
<b><u>%s</u></b>?", utf);
+                               GtkWidget *dialog;
+                               dialog = create_confirm_dialog (dialog_text,
+                                       (E2_BUTTON_CANCEL | E2_BUTTON_NO |
+                                        E2_BUTTON_YES_TO_ALL | E2_BUTTON_YES));
+                               gint result = gtk_dialog_run (GTK_DIALOG 
(dialog));
+                               gtk_widget_destroy (dialog);
+
+                               switch (result)
+                               {
+                                       case 111:
+                                               //apply is yes to all
+                                               check = FALSE;
+                                       case GTK_RESPONSE_YES:
+                                               progbarstruct.process_id = 
exec_and_capture_output_threaded_progbar(command);   
+                                               gtk_widget_show(window);
+                                       case GTK_RESPONSE_NO:
+                                       default:
+                                               //CANCEL
+                                               break;
+                               }
+                               if (result == GTK_RESPONSE_CANCEL)
                                        break;
+                               else if (result == GTK_RESPONSE_NO)
+                                       continue;
+                               g_free (utf);
                        }
-                       if (result == GTK_RESPONSE_CANCEL)
-                               break;
-                       else if (result == GTK_RESPONSE_NO)
-                               continue;
                }
     else
                {
@@ -384,7 +391,7 @@
                        gtk_widget_show(window);
                }
                                
-               shorten((((FileInfo *)const_list->data)->filename), src_dots, 
&src_diff);
+               shorten((gchar *)const_list->data, src_dots, &src_diff);
                shorten(dest_dir, dest_dots, &dest_diff);
 
                while (access(dest, F_OK) == -1)
@@ -400,7 +407,7 @@
                                        "to %s%s" 
                                        "\n"
                                        " copying file/directory %d of %d", 
-                                       src_dots, ((((FileInfo 
*)const_list->data)->filename)+src_diff),
+                                       src_dots, (((gchar 
*)const_list->data)+src_diff),
                                        dest_dots, (dest_dir+dest_diff), 
                                        i, progbarstruct.file_sum);
                        g_snprintf(progbartext, sizeof (progbartext), 

Other related posts: