[Xfce4-commits] r26489 - xarchiver/trunk/src

Giuseppe Torelli colossus at xfce.org
Mon Dec 17 14:21:53 CET 2007


Author: colossus
Date: 2007-12-17 13:21:53 +0000 (Mon, 17 Dec 2007)
New Revision: 26489

Modified:
   xarchiver/trunk/src/add_dialog.c
   xarchiver/trunk/src/archive.c
   xarchiver/trunk/src/archive.h
   xarchiver/trunk/src/bzip2.c
   xarchiver/trunk/src/deb.c
   xarchiver/trunk/src/extract_dialog.c
   xarchiver/trunk/src/rpm.c
   xarchiver/trunk/src/window.c
Log:
Fixed double creation of temp directory when viewing files inside tar archives.


Modified: xarchiver/trunk/src/add_dialog.c
===================================================================
--- xarchiver/trunk/src/add_dialog.c	2007-12-16 20:42:10 UTC (rev 26488)
+++ xarchiver/trunk/src/add_dialog.c	2007-12-17 13:21:53 UTC (rev 26489)
@@ -498,10 +498,7 @@
 
 		case XARCHIVETYPE_TAR_GZ:
 		if ( g_file_test ( archive->escaped_path , G_FILE_TEST_EXISTS ) )
-		{
-			g_print ("Son qui\n");
 			xa_add_delete_tar_bzip2_gzip ( names , archive, 1 , 1 );
-		}
 		/* This is executed when the archive is newly created */
 		else
 			command = g_strconcat (tar, " ",

Modified: xarchiver/trunk/src/archive.c
===================================================================
--- xarchiver/trunk/src/archive.c	2007-12-16 20:42:10 UTC (rev 26488)
+++ xarchiver/trunk/src/archive.c	2007-12-17 13:21:53 UTC (rev 26489)
@@ -200,6 +200,7 @@
 		xa_delete_temp_directory (archive,0);
 		gtk_widget_hide(viewport2);
 		g_free (archive->tmp);
+		archive->tmp = NULL;
 	}
 
 	if (archive->passwd != NULL)
@@ -226,16 +227,16 @@
 {
 	gchar *command;
 	gboolean result;
-		
-	chdir (archive->tmp);
 	command = g_strconcat ("rm -rf ",archive->tmp,NULL);
 	result = xa_run_command (archive,command,flag);
 	g_free (command);
 	return result;
 }
 
-gboolean xa_create_temp_directory (gchar tmp_dir[])
+gboolean xa_create_temp_directory (XArchive *archive,gchar tmp_dir[])
 {
+	if (archive->tmp != NULL)
+		return TRUE;
 	//TODO use the user set tmp dir in the pref dialog
 	strcpy (tmp_dir,"/tmp/xa-XXXXXX");
 	if (mkdtemp (tmp_dir) == 0)
@@ -245,6 +246,7 @@
 		Update_StatusBar (_("Operation failed."));
 		return FALSE;
 	}
+	archive->tmp = strdup(tmp_dir);
 	return TRUE;
 }
 

Modified: xarchiver/trunk/src/archive.h
===================================================================
--- xarchiver/trunk/src/archive.h	2007-12-16 20:42:10 UTC (rev 26488)
+++ xarchiver/trunk/src/archive.h	2007-12-17 13:21:53 UTC (rev 26489)
@@ -120,18 +120,18 @@
 XArchive *xa_init_archive_structure ();
 void xa_clean_archive_structure ( XArchive *archive);
 gboolean xa_dump_child_error_messages (GIOChannel *ioc, GIOCondition cond, gpointer data);
-gboolean xa_create_temp_directory (gchar tmp_dir[]);
-gboolean xa_delete_temp_directory (XArchive *archive,gboolean flag);
+gboolean xa_create_temp_directory(XArchive *archive,gchar tmp_dir[]);
+gboolean xa_delete_temp_directory(XArchive *archive,gboolean flag);
 gboolean xa_run_command (XArchive *archive,gchar *command,gboolean set_gui);
 gint xa_find_archive_index (gint page_num);
 gint xa_get_new_archive_idx();
 XEntry *xa_alloc_memory_for_each_row ( guint nc,GType column_types[]);
-void xa_free_entry (XArchive *archive,XEntry *entry);
+void xa_free_entry(XArchive *archive,XEntry *entry);
 XEntry *xa_find_child_entry(XEntry *entry, gchar *string);
-XEntry *xa_set_archive_entries_for_each_row (XArchive *archive,gchar *filename,gpointer *items);
+XEntry *xa_set_archive_entries_for_each_row(XArchive *archive,gchar *filename,gpointer *items);
 gpointer *xa_fill_archive_entry_columns_for_each_row (XArchive *archive,XEntry *entry,gpointer *items);
-void xa_update_window_with_archive_entries (XArchive *archive,XEntry *entry);
-XEntry* xa_find_entry_from_path (XEntry *root_entry,const gchar *fullpathname);
+void xa_update_window_with_archive_entries(XArchive *archive,XEntry *entry);
+XEntry* xa_find_entry_from_path(XEntry *root_entry,const gchar *fullpathname);
 gchar *xa_build_full_path_name_from_entry(XEntry *entry);
 void xa_entries_to_filelist(XEntry *, GSList **, gchar *);
 void xa_destroy_filelist(GSList *file_list);

Modified: xarchiver/trunk/src/bzip2.c
===================================================================
--- xarchiver/trunk/src/bzip2.c	2007-12-16 20:42:10 UTC (rev 26488)
+++ xarchiver/trunk/src/bzip2.c	2007-12-17 13:21:53 UTC (rev 26489)
@@ -90,7 +90,7 @@
 
 		char *names[]= {(_("Compressed")),(_("Size"))};
 		xa_create_liststore (archive,names);
-		result = xa_create_temp_directory (tmp_dir);
+		result = xa_create_temp_directory (archive,tmp_dir);
 		if (result == 0)
 			return;
 

Modified: xarchiver/trunk/src/deb.c
===================================================================
--- xarchiver/trunk/src/deb.c	2007-12-16 20:42:10 UTC (rev 26488)
+++ xarchiver/trunk/src/deb.c	2007-12-17 13:21:53 UTC (rev 26489)
@@ -26,27 +26,28 @@
 void xa_open_deb ( XArchive *archive )
 {
 	gchar *command = NULL;
+	gchar *dummy = NULL;
 	gchar *archive_no_path = NULL;
 	gboolean result;
 	unsigned short int i;
 	gchar tmp_dir[14] = "";
 
 	/* Create a unique tmp dir in /tmp */
-	result = xa_create_temp_directory (tmp_dir);
+	result = xa_create_temp_directory (archive,tmp_dir);
 	if (result == 0)
 		return;
 
 	archive_no_path = g_strrstr (archive->escaped_path,"/");
 	if (archive_no_path == NULL)
-		archive->tmp = g_strconcat (" ",tmp_dir,"/",archive->escaped_path,NULL);
+		dummy = g_strconcat (" ",tmp_dir,"/",archive->escaped_path,NULL);
 	else
 	{
 		archive_no_path++;
-		archive->tmp = g_strconcat (" ",tmp_dir,"/",archive_no_path,NULL);
+		dummy = g_strconcat (" ",tmp_dir,"/",archive_no_path,NULL);
 	}
 
 	/* Copy the .deb archive to the unique dir */
-	command = g_strconcat ("cp ",archive->escaped_path,archive->tmp,NULL);
+	command = g_strconcat ("cp ",archive->escaped_path," ",archive->tmp,NULL);
 	result = xa_run_command (archive,command,0);
 	g_free (command);
 	if (result == FALSE)
@@ -54,13 +55,12 @@
 
 	/* Ok, let's now extract the .deb archive with ar */
 	chdir (tmp_dir);
-	command = g_strconcat ("ar xv" , archive->tmp, NULL);
+	command = g_strconcat ("ar xv" , dummy, NULL);
 	result = xa_run_command (archive,command,0);
 	g_free (command);
-	g_free (archive->tmp);
+	g_free (dummy);
 
-	archive->tmp = g_strdup(tmp_dir);
-	chdir (tmp_dir);
+	chdir (archive->tmp);
 	unlink ("control.tar.gz");
 	unlink ("debian-binary");
 	/* Delete the .deb archive copied to the unique dir */
@@ -73,7 +73,7 @@
 		return;
 
 	/* Finally, let's show the content of data.tar.gz in the unique dir */
-	command = g_strconcat ("tar tfzv ",tmp_dir,"/data.tar.gz", NULL);
+	command = g_strconcat ("tar tfzv ",archive->tmp,"/data.tar.gz", NULL);
 	archive->has_properties = archive->can_extract = TRUE;
 	archive->can_add = archive->has_test = archive->has_sfx = FALSE;
 	archive->dummy_size = 0;

Modified: xarchiver/trunk/src/extract_dialog.c
===================================================================
--- xarchiver/trunk/src/extract_dialog.c	2007-12-16 20:42:10 UTC (rev 26488)
+++ xarchiver/trunk/src/extract_dialog.c	2007-12-17 13:21:53 UTC (rev 26489)
@@ -819,7 +819,7 @@
 	}
 	else
 	{
-		/* *Here we need to fill a GSList with all the entries in the archive so that we can use mv on all of them */
+		/* Here we need to fill a GSList with all the entries in the archive so that we can use mv on all of them */
 		XEntry *entry = archive->root_entry;
 
 		while(entry)
@@ -830,11 +830,10 @@
 	}
 	filenames = g_slist_reverse(xxx);
 
-	result = xa_create_temp_directory (tmp_dir);
+	result = xa_create_temp_directory (archive,tmp_dir);
 	if (result == 0)
 		return FALSE;
 
-	archive->tmp = strdup(tmp_dir);
 	if (cpio_flag)
 	{
 		chdir (archive->tmp);
@@ -844,7 +843,8 @@
 		command = g_strconcat ( string, archive->escaped_path,
 										archive->overwrite ? " --overwrite" : " --keep-old-files",
 										archive->tar_touch ? " --touch" : "",
-										" -C " , tmp_dir , names->str, NULL );
+										" --no-wildcards -C ",
+										archive->tmp,names->str,NULL);
 	result = xa_run_command (archive,command,0);
 	g_string_free (names, TRUE);
 	g_free (command);
@@ -856,7 +856,6 @@
 		Update_StatusBar (_("Operation canceled."));
 		return FALSE;
 	}
-	chdir (archive->tmp);
 	while (filenames)
 	{
 		gchar *unescaped = xa_escape_bad_chars ( (gchar*)filenames->data , "$\'`\"\\!?* ()&|@#:;");
@@ -866,7 +865,12 @@
 		filenames = filenames->next;
 	}
 	xa_destroy_filelist (filenames);
+	if (extract_path == NULL)
+		extract_path = archive->tmp;
+
+	chdir (archive->tmp);
 	command = g_strconcat ( "mv -f ", unescaped_names->str, " " , extract_path , NULL );
+
 	result = xa_run_command (archive,command,0);
 	g_free (command);
 	g_slist_free (filenames);
@@ -878,12 +882,6 @@
 		Update_StatusBar (_("Operation canceled."));
 		return FALSE;
 	}
-
-	if (cpio_flag)
-		xa_delete_temp_directory (archive,0);
-	else
-		xa_delete_temp_directory (archive,1);
-
 	return result;
 }
 

Modified: xarchiver/trunk/src/rpm.c
===================================================================
--- xarchiver/trunk/src/rpm.c	2007-12-16 20:42:10 UTC (rev 26488)
+++ xarchiver/trunk/src/rpm.c	2007-12-17 13:21:53 UTC (rev 26489)
@@ -96,12 +96,11 @@
 	fclose (stream);
 
 	/* Create a unique temp dir in /tmp */
-	result = xa_create_temp_directory (tmp_dir);
+	result = xa_create_temp_directory (archive,tmp_dir);
 	if (result == 0)
 		return;
 
-	archive->tmp = g_strdup(tmp_dir);
-	gzip_tmp = g_strconcat (tmp_dir,"/file.gz_bz",NULL);
+	gzip_tmp = g_strconcat (archive->tmp,"/file.gz_bz",NULL);
 	ibs = g_strdup_printf ( "%u" , offset );
 
 	//Now I run dd to have the bzip2 / gzip compressed cpio archive in /tmp

Modified: xarchiver/trunk/src/window.c
===================================================================
--- xarchiver/trunk/src/window.c	2007-12-16 20:42:10 UTC (rev 26488)
+++ xarchiver/trunk/src/window.c	2007-12-17 13:21:53 UTC (rev 26489)
@@ -1346,7 +1346,7 @@
 	xa_close_archive(NULL,NULL);
 }
 
-void xa_view_file_inside_archive (GtkMenuItem *menuitem , gpointer user_data)
+void xa_view_file_inside_archive (GtkMenuItem *menuitem,gpointer user_data)
 {
 	gchar *command = NULL;
 	gchar tmp_dir[14] = "";
@@ -1410,11 +1410,7 @@
 	archive[idx]->full_path = 0;
 	archive[idx]->overwrite = 1;
 
-	if (archive[idx]->tmp == NULL)
-	{
-		result = xa_create_temp_directory(tmp_dir);
-		archive[idx]->tmp = g_strdup(tmp_dir);
-	}
+	result = xa_create_temp_directory(archive[idx],tmp_dir);
 
 	command = xa_extract_single_files(archive[idx],names,archive[idx]->tmp);
 	g_string_free (names,TRUE);
@@ -1599,7 +1595,8 @@
 	gchar *esc_filename = NULL;
 
 	quoted_filename = g_shell_quote(filename);
-	if (archive->status != XA_ARCHIVESTATUS_ADD)
+	if (archive->status != XA_ARCHIVESTATUS_ADD && archive->type != XARCHIVETYPE_TAR
+		&& archive->type != XARCHIVETYPE_TAR_BZ2 && archive->type != XARCHIVETYPE_TAR_GZ)
 	{
 		if (strstr(filename,"[") || strstr(filename,"]"))
 		{



More information about the Xfce4-commits mailing list