Author: colossus
Date: 2008-10-22 07:22:09 +0000 (Wed, 22 Oct 2008)
New Revision: 28352

Modified:
   xarchiver/trunk/TODO
   xarchiver/trunk/src/add_dialog.c
   xarchiver/trunk/src/bzip2.c
   xarchiver/trunk/src/interface.c
   xarchiver/trunk/src/main.c
   xarchiver/trunk/src/string_utils.c
   xarchiver/trunk/src/window.c
Log:
Fixed extraction of lzma/bzip2 compressed files.
Fixed missed deletion of socket file in /tmp when using the switches from 
cmd-line.
Fixed crashes with cut/copy/paste operations.
Updated TODO file.


Modified: xarchiver/trunk/TODO
===================================================================
--- xarchiver/trunk/TODO        2008-10-21 21:23:05 UTC (rev 28351)
+++ xarchiver/trunk/TODO        2008-10-22 07:22:09 UTC (rev 28352)
@@ -1,3 +1,2 @@
 - reduce the loading time when opening large archives.
 - to fix bugs #4299 and #3235.
-- to fix crashes when using cut/copy/paste

Modified: xarchiver/trunk/src/add_dialog.c
===================================================================
--- xarchiver/trunk/src/add_dialog.c    2008-10-21 21:23:05 UTC (rev 28351)
+++ xarchiver/trunk/src/add_dialog.c    2008-10-22 07:22:09 UTC (rev 28352)
@@ -434,7 +434,7 @@
 void xa_execute_add_commands (XArchive *archive,GSList *list,gchar 
*compression_string)
 {
        gchar *new_path = NULL;
-       gchar *esc,*esc2;
+       gchar *esc,*esc2,*basename;
        gboolean result = FALSE;
        GString *items;
        gchar *command = NULL;
@@ -467,7 +467,9 @@
                                g_string_append_c(items,' ');
                                slist = slist->next;
                        }
-                       command = g_strconcat ("cp -r ",items->str," 
",new_path,NULL);
+                       basename = g_path_get_basename(items->str);
+                       command = g_strconcat ("cp -f ",basename," 
",new_path,NULL);
+                       g_free(basename);
                        g_free(new_path);
                        g_string_free(items,TRUE);
                        cmd_list = g_slist_append(cmd_list,command);
@@ -479,9 +481,9 @@
        if (archive->working_dir != NULL)
        {
                g_free(archive->working_dir);
-               archive->working_dir = NULL;
+               archive->working_dir = g_path_get_dirname(list->data);
        }
-       archive->working_dir = g_path_get_dirname(list->data);
+       
        while (list)
        {
                
xa_recurse_local_directory((gchar*)list->data,&dirlist,archive->add_recurse,archive->type);

Modified: xarchiver/trunk/src/bzip2.c
===================================================================
--- xarchiver/trunk/src/bzip2.c 2008-10-21 21:23:05 UTC (rev 28351)
+++ xarchiver/trunk/src/bzip2.c 2008-10-22 07:22:09 UTC (rev 28352)
@@ -33,7 +33,7 @@
        gchar *_filename;
        gpointer item[2];
        gboolean result;
-       int len = 0;
+       gint len = 0;
 
        if (g_str_has_suffix(archive->escaped_path,".tar.bz2") || 
g_str_has_suffix (archive->escaped_path,".tar.bz")
        || g_str_has_suffix ( archive->escaped_path , ".tbz") || 
g_str_has_suffix (archive->escaped_path,".tbz2") )
@@ -66,11 +66,13 @@
                {
                        archive->format = "BZIP2";
                        executable = "bzip2 ";
+                       len = 4;
                }
                else
                {
                        archive->format = "LZMA";
                        executable = "lzma ";
+                       len = 5;
                }
                archive->can_add = archive->has_test = archive->has_sfx = FALSE;
                archive->has_properties = archive->can_extract = TRUE;
@@ -108,10 +110,6 @@
 
                /* and let's get its uncompressed file size */
                dot = strrchr(_filename,'.');
-               if (strcmp(executable,"lzma") == 0)
-                       len = 5;
-               else
-                       len = 4;
                if (_filename || G_LIKELY(dot))
                {
                        _filename++;
@@ -174,9 +172,20 @@
 gboolean lzma_bzip2_extract (XArchive *archive,GSList *dummy)
 {
        GSList *list = NULL;
-       gchar  *command = NULL,*filename = NULL, *dot = NULL, *filename_noext = 
NULL;
+       gchar  *command = NULL,*executable,*filename = NULL, *dot = NULL, 
*filename_noext = NULL;
        gboolean result = FALSE;
+       gint len = 0;
 
+       if (archive->type == XARCHIVETYPE_BZIP2)
+       {
+               executable = "bzip2 ";
+               len = 4;
+       }
+       else
+       {
+               executable = "lzma ";
+               len = 5;
+       }
        filename = xa_remove_path_from_archive_name(archive->escaped_path);
        dot = strrchr(filename,'.');
        if (G_LIKELY(dot))
@@ -187,20 +196,9 @@
        else
                filename_noext = filename;
 
-       if (archive->tmp == NULL)
-               result = xa_create_temp_directory(archive);
-
-       dot = g_strconcat(archive->tmp,"/",filename_noext,NULL);
+       command = g_strconcat("sh -c \"",executable, " 
",archive->escaped_path," -dc > 
",archive->extraction_path,"/",filename_noext,"\"",NULL);
        g_free(filename_noext);
-
-       if (strcmp(archive->tmp,archive->extraction_path) != 0)
-       {
-               command = g_strconcat("cp -f ",dot," 
",archive->extraction_path,NULL);
-               list = g_slist_append(list,command);
-               result = xa_run_command (archive,list);
-       }
-       else
-               result = TRUE;
-       g_free(dot);    
+       list = g_slist_append(list,command);
+       result = xa_run_command (archive,list);
        return result;
 }

Modified: xarchiver/trunk/src/interface.c
===================================================================
--- xarchiver/trunk/src/interface.c     2008-10-21 21:23:05 UTC (rev 28351)
+++ xarchiver/trunk/src/interface.c     2008-10-22 07:22:09 UTC (rev 28352)
@@ -1470,7 +1470,7 @@
 {
        GtkTreeModel *model;
        GtkTreePath *path;
-       static GtkTreePath  *lastpath;
+       static GtkTreePath *lastpath;
 
        model = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
        gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW 
(widget),x,y,&path,NULL);

Modified: xarchiver/trunk/src/main.c
===================================================================
--- xarchiver/trunk/src/main.c  2008-10-21 21:23:05 UTC (rev 28351)
+++ xarchiver/trunk/src/main.c  2008-10-22 07:22:09 UTC (rev 28352)
@@ -228,6 +228,9 @@
                }
                if (archive != NULL)
                        xa_clean_archive_structure (archive);
+               #ifdef HAVE_SOCKET
+                       socket_finalize();
+               #endif
        }
        else
        {

Modified: xarchiver/trunk/src/string_utils.c
===================================================================
--- xarchiver/trunk/src/string_utils.c  2008-10-21 21:23:05 UTC (rev 28351)
+++ xarchiver/trunk/src/string_utils.c  2008-10-22 07:22:09 UTC (rev 28352)
@@ -244,6 +244,8 @@
        gchar *slash;
        int len = 0;
 
+       if (working_dir == NULL)
+               return filename;
        len = strlen(working_dir)+1;
        slash = g_strrstr(filename,"/");
        if (slash == NULL || ! g_path_is_absolute(filename))

Modified: xarchiver/trunk/src/window.c
===================================================================
--- xarchiver/trunk/src/window.c        2008-10-21 21:23:05 UTC (rev 28351)
+++ xarchiver/trunk/src/window.c        2008-10-22 07:22:09 UTC (rev 28352)
@@ -2334,9 +2334,6 @@
        GtkSelectionData *selection;
        XAClipboard *paste_data;
        GSList *list = NULL;
-       gchar *dummy_ex_path = NULL;
-       gboolean result = FALSE;
-       gboolean overwrite;
 
        current_page = gtk_notebook_get_current_page(notebook);
        idx = xa_find_archive_index(current_page);
@@ -2348,39 +2345,10 @@
        paste_data = 
xa_get_paste_data_from_clipboard_selection((char*)selection->data);
        gtk_selection_data_free (selection);
 
-       /* Let's extract the selected files to the archive tmp dir */
-       if (paste_data->cut_copy_archive->has_passwd)
-       {
-               if(xa_create_password_dialog(paste_data->cut_copy_archive) == 
NULL)
-                       return;
-       }
-       if (paste_data->cut_copy_archive->extraction_path)
-       {
-               dummy_ex_path = 
g_strdup(paste_data->cut_copy_archive->extraction_path);
-               g_free(paste_data->cut_copy_archive->extraction_path);
-       }
-       xa_create_temp_directory(paste_data->cut_copy_archive);
-       paste_data->cut_copy_archive->extraction_path = 
g_strdup(paste_data->cut_copy_archive->tmp);
+       /* Let's add the already extracted files in the tmp dir to the current 
archive dir */
        list = xa_slist_copy(paste_data->files);
-       overwrite = paste_data->cut_copy_archive->overwrite;
-       paste_data->cut_copy_archive->overwrite = TRUE;
-       result = (*paste_data->cut_copy_archive->extract) 
(paste_data->cut_copy_archive,list);
-       paste_data->cut_copy_archive->overwrite = overwrite;
-
-       g_free(paste_data->cut_copy_archive->extraction_path);
-       paste_data->cut_copy_archive->extraction_path = NULL;
-       if (dummy_ex_path)
-       {
-               paste_data->cut_copy_archive->extraction_path = 
g_strdup(dummy_ex_path);
-               g_free(dummy_ex_path);
-       }
-       if (result == FALSE)
-               return;
-
-       /* Now let's add the extracted files in the tmp dir to the current 
archive dir */
-       list = xa_slist_copy(paste_data->files);
        chdir (paste_data->cut_copy_archive->tmp);
-       //TODO put the above in archive[idx]->tmp
+
        xa_execute_add_commands(archive[idx],list,NULL);
        if (archive[idx]->status == XA_ARCHIVESTATUS_ERROR)
                return;
@@ -2398,6 +2366,9 @@
        GtkClipboard *clipboard;
        XAClipboard *clipboard_data = NULL;
        GSList *files = NULL;
+       gchar *dummy_ex_path = NULL;
+       gboolean result = FALSE;
+       gboolean overwrite;
        GtkTreeSelection *selection;
        GtkTargetEntry targets[] = 
        {
@@ -2412,11 +2383,38 @@
        if (clipboard_data == NULL)
                return;
 
-       clipboard_data->files = files;
+       clipboard_data->files = xa_slist_copy(files);
        clipboard_data->mode  = mode;
        gtk_clipboard_set_with_data (clipboard,targets,G_N_ELEMENTS 
(targets),xa_clipboard_get,xa_clipboard_clear,(gpointer)archive);
        archive->clipboard_data = clipboard_data;
        gtk_widget_set_sensitive(paste,TRUE);
+
+       /* Let's extract the selected files to the archive tmp dir */
+       if (archive->has_passwd)
+       {
+               if(xa_create_password_dialog(archive) == NULL)
+                       return;
+       }
+       if (archive->extraction_path)
+       {
+               dummy_ex_path = g_strdup(archive->extraction_path);
+               g_free(archive->extraction_path);
+       }
+       xa_create_temp_directory(archive);
+       archive->extraction_path = g_strdup(archive->tmp);
+       overwrite = archive->overwrite;
+       archive->overwrite = TRUE;
+
+       result = (*archive->extract) (archive,files);
+       archive->overwrite = overwrite;
+       g_free(archive->extraction_path);
+
+       archive->extraction_path = NULL;
+       if (dummy_ex_path)
+       {
+               archive->extraction_path = g_strdup(dummy_ex_path);
+               g_free(dummy_ex_path);
+       }
 }
 
 XAClipboard *xa_get_paste_data_from_clipboard_selection(const char *data)

_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to