Author: colossus
Date: 2007-08-23 11:30:28 +0000 (Thu, 23 Aug 2007)
New Revision: 26003
Modified:
xarchiver/trunk/src/7zip.c
xarchiver/trunk/src/archive.c
xarchiver/trunk/src/archive.h
xarchiver/trunk/src/arj.c
xarchiver/trunk/src/extract_dialog.c
xarchiver/trunk/src/extract_dialog.h
xarchiver/trunk/src/rpm.c
xarchiver/trunk/src/window.c
xarchiver/trunk/src/window.h
Log:
Fixed seg-fault when using File->Close with RPM archives.
Moved function xa_create_temp_directory and xa_delete_temp_directory to
archive.c.
Modified: xarchiver/trunk/src/7zip.c
===================================================================
--- xarchiver/trunk/src/7zip.c 2007-08-22 20:44:55 UTC (rev 26002)
+++ xarchiver/trunk/src/7zip.c 2007-08-23 11:30:28 UTC (rev 26003)
@@ -63,7 +63,6 @@
XEntry *entry;
gchar *filename;
gpointer item[5];
- unsigned short int i = 0;
gint linesize = 0,n = 0,a = 0;
gboolean dir = FALSE;
Modified: xarchiver/trunk/src/archive.c
===================================================================
--- xarchiver/trunk/src/archive.c 2007-08-22 20:44:55 UTC (rev 26002)
+++ xarchiver/trunk/src/archive.c 2007-08-23 11:30:28 UTC (rev 26003)
@@ -23,6 +23,8 @@
#include "mime.h"
#include "support.h"
#include "window.h"
+#include <sys/types.h>
+#include <dirent.h>
static gboolean xa_process_output (GIOChannel *ioc, GIOCondition cond,
gpointer data);
@@ -226,6 +228,92 @@
g_free (archive);
}
+gboolean xa_delete_temp_directory (gchar *dir_name, gboolean flag)
+{
+ DIR *dirp;
+ struct dirent *dp;
+
+ chdir (dir_name);
+ dirp = opendir(dir_name);
+ if (dirp == NULL)
+ return FALSE;
+
+ while ((dp = readdir(dirp)) != NULL)
+ {
+ if (dp->d_name[0] != '.')
+ unlink (dp->d_name);
+ }
+ closedir(dirp);
+ rmdir (dir_name);
+ return TRUE;
+}
+
+gboolean xa_create_temp_directory ( gchar tmp_dir[] )
+{
+ strcpy (tmp_dir,"/tmp/xa-XXXXXX");
+ if ( mkdtemp ( tmp_dir ) == 0)
+ {
+ response = xa_show_message_dialog (GTK_WINDOW
(MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("Can't create
temporary directory in /tmp:"),g_strerror(errno) );
+ gtk_widget_set_sensitive (Stop_button, FALSE);
+ Update_StatusBar (_("Operation failed."));
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean xa_run_command ( gchar *command , gboolean watch_child_flag )
+{
+ gint current_page;
+ gint idx;
+ int status;
+ gboolean waiting = TRUE;
+ int ps;
+
+ current_page = gtk_notebook_get_current_page (notebook);
+ idx = xa_find_archive_index ( current_page );
+
+ archive[idx]->parse_output = 0;
+ xa_spawn_async_process ( archive[idx],command,0);
+ if ( archive[idx]->child_pid == 0 )
+ return FALSE;
+
+ gtk_widget_show (viewport2);
+ while (waiting)
+ {
+ ps = waitpid ( archive[idx]->child_pid, &status, WNOHANG);
+ if (ps < 0)
+ waiting = FALSE;
+ else
+ gtk_main_iteration_do (FALSE);
+ }
+ //TODO:
+ /*if (watch_child_flag)
+ {
+ xa_watch_child (archive[idx]->child_pid, status, archive[idx]);
+ return TRUE;
+ }
+ else
+ {
+ if ( WIFEXITED (status) )
+ {
+ if ( WEXITSTATUS (status) )
+ {
+ gtk_tooltips_disable ( pad_tooltip );
+ gtk_widget_hide ( pad_image );
+ gtk_widget_hide ( viewport2 );
+ response = xa_show_message_dialog (GTK_WINDOW
(MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_QUESTION,GTK_BUTTONS_YES_NO,_("An
error occurred while accessing the archive."),_("Do you want to view the
command line output?") );
+ if (response == GTK_RESPONSE_YES)
+ xa_show_cmd_line_output (NULL);
+ archive[idx]->status = XA_ARCHIVESTATUS_IDLE;
+ gtk_widget_set_sensitive (Stop_button,FALSE);
+ Update_StatusBar ( _("Operation failed."));
+ return FALSE;
+ }
+ }
+ }*/
+ return TRUE;
+}
+
gint xa_find_archive_index ( gint page_num )
{
GtkWidget *scrollwindow;
Modified: xarchiver/trunk/src/archive.h
===================================================================
--- xarchiver/trunk/src/archive.h 2007-08-22 20:44:55 UTC (rev 26002)
+++ xarchiver/trunk/src/archive.h 2007-08-23 11:30:28 UTC (rev 26003)
@@ -119,6 +119,9 @@
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 ( gchar *dir_name, gboolean flag);
+gboolean xa_run_command ( gchar *command , gboolean watch_child_flag );
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[]);
Modified: xarchiver/trunk/src/arj.c
===================================================================
--- xarchiver/trunk/src/arj.c 2007-08-22 20:44:55 UTC (rev 26002)
+++ xarchiver/trunk/src/arj.c 2007-08-23 11:30:28 UTC (rev 26003)
@@ -56,7 +56,6 @@
XEntry *entry;
gpointer item[8];
unsigned int linesize,n,a;
- gboolean dir = FALSE;
if (last_line)
return;
Modified: xarchiver/trunk/src/extract_dialog.c
===================================================================
--- xarchiver/trunk/src/extract_dialog.c 2007-08-22 20:44:55 UTC (rev
26002)
+++ xarchiver/trunk/src/extract_dialog.c 2007-08-23 11:30:28 UTC (rev
26003)
@@ -889,31 +889,6 @@
return result;
}
-gboolean xa_delete_temp_directory ( gchar *dir_name, gboolean flag)
-{
- gchar *command;
- gboolean result;
-
- chdir (dir_name);
- command = g_strconcat ( "rm -rf ", dir_name , NULL );
- result = xa_run_command (command , flag );
- g_free (command);
- return result;
-}
-
-gboolean xa_create_temp_directory ( gchar tmp_dir[] )
-{
- strcpy (tmp_dir,"/tmp/xa-XXXXXX");
- if ( mkdtemp ( tmp_dir ) == 0)
- {
- response = xa_show_message_dialog (GTK_WINDOW
(MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("Can't create
temporary directory in /tmp:"),g_strerror(errno) );
- gtk_widget_set_sensitive (Stop_button, FALSE);
- Update_StatusBar (_("Operation failed."));
- return FALSE;
- }
- return TRUE;
-}
-
void xa_choose_extraction_directory (GtkWidget *widget, gpointer data)
{
Extract_dialog_data *dialog_data = data;
Modified: xarchiver/trunk/src/extract_dialog.h
===================================================================
--- xarchiver/trunk/src/extract_dialog.h 2007-08-22 20:44:55 UTC (rev
26002)
+++ xarchiver/trunk/src/extract_dialog.h 2007-08-23 11:30:28 UTC (rev
26003)
@@ -68,9 +68,7 @@
void update_fresh_toggled_cb (GtkToggleButton *button, Extract_dialog_data
*data);
gchar *xa_parse_extract_dialog_options ( XArchive *archive ,
Extract_dialog_data *dialog_data, GtkTreeSelection *selection);
gchar *xa_extract_single_files ( XArchive *archive , GString *files, gchar
*path);
-gboolean xa_create_temp_directory (gchar tmp_dir[]);
gboolean xa_extract_tar_without_directories ( gchar *string, gchar
*escaped_path, gboolean overwrite, gboolean tar_touch, gchar *extract_path ,
gboolean cpio_flag);
-gboolean xa_delete_temp_directory ( gchar *dir_name, gboolean flag);
void xa_choose_extraction_directory (GtkWidget *widget, gpointer data);
#endif
Modified: xarchiver/trunk/src/rpm.c
===================================================================
--- xarchiver/trunk/src/rpm.c 2007-08-22 20:44:55 UTC (rev 26002)
+++ xarchiver/trunk/src/rpm.c 2007-08-23 11:30:28 UTC (rev 26003)
@@ -172,11 +172,13 @@
g_io_add_watch (input_ioc,
G_IO_IN|G_IO_OUT|G_IO_PRI|G_IO_ERR|G_IO_HUP|G_IO_NVAL, WriteCPIOInput, NULL );
g_io_channel_set_encoding (input_ioc, NULL , NULL);
- ioc_cpio = g_io_channel_new_file ( gzip , "r" , NULL );
+ ioc_cpio = g_io_channel_new_file (gzip , "r" , NULL);
+ g_free (gzip);
g_io_channel_set_encoding (ioc_cpio , NULL , NULL);
g_io_channel_set_flags ( ioc_cpio , G_IO_FLAG_NONBLOCK , NULL );
g_child_watch_add ( archive[idx]->child_pid, (GChildWatchFunc)
xa_watch_child, archive[idx]);
+
return NULL;
}
Modified: xarchiver/trunk/src/window.c
===================================================================
--- xarchiver/trunk/src/window.c 2007-08-22 20:44:55 UTC (rev 26002)
+++ xarchiver/trunk/src/window.c 2007-08-23 11:30:28 UTC (rev 26003)
@@ -1637,59 +1637,6 @@
g_free (fullname);
}
-gboolean xa_run_command ( gchar *command , gboolean watch_child_flag )
-{
- gint current_page;
- gint idx;
- int status;
- gboolean waiting = TRUE;
- int ps;
-
- current_page = gtk_notebook_get_current_page (notebook);
- idx = xa_find_archive_index ( current_page );
-
- archive[idx]->parse_output = 0;
- xa_spawn_async_process ( archive[idx],command,0);
- if ( archive[idx]->child_pid == 0 )
- return FALSE;
-
- gtk_widget_show (viewport2);
- while (waiting)
- {
- ps = waitpid ( archive[idx]->child_pid, &status, WNOHANG);
- if (ps < 0)
- waiting = FALSE;
- else
- gtk_main_iteration_do (FALSE);
- }
- //TODO:
- /*if (watch_child_flag)
- {
- xa_watch_child (archive[idx]->child_pid, status, archive[idx]);
- return TRUE;
- }
- else
- {
- if ( WIFEXITED (status) )
- {
- if ( WEXITSTATUS (status) )
- {
- gtk_tooltips_disable ( pad_tooltip );
- gtk_widget_hide ( pad_image );
- gtk_widget_hide ( viewport2 );
- response = xa_show_message_dialog (GTK_WINDOW
(MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_QUESTION,GTK_BUTTONS_YES_NO,_("An
error occurred while accessing the archive."),_("Do you want to view the
command line output?") );
- if (response == GTK_RESPONSE_YES)
- xa_show_cmd_line_output (NULL);
- archive[idx]->status = XA_ARCHIVESTATUS_IDLE;
- gtk_widget_set_sensitive (Stop_button,FALSE);
- Update_StatusBar ( _("Operation failed."));
- return FALSE;
- }
- }
- }*/
- return TRUE;
-}
-
void Update_StatusBar ( gchar *msg)
{
gtk_label_set_text (GTK_LABEL (info_label), msg);
Modified: xarchiver/trunk/src/window.h
===================================================================
--- xarchiver/trunk/src/window.h 2007-08-22 20:44:55 UTC (rev 26002)
+++ xarchiver/trunk/src/window.h 2007-08-23 11:30:28 UTC (rev 26003)
@@ -96,7 +96,6 @@
void ConcatenateFileNames2 (gchar *filename , GString *data);
void xa_cat_filenames (GtkTreeModel *model, GtkTreePath *treepath, GtkTreeIter
*iter, GString *data);
void xa_cat_filenames_basename (GtkTreeModel *model, GtkTreePath *treepath,
GtkTreeIter *iter, GString *data);
-gboolean xa_run_command ( gchar *command , gboolean watch_child_flag );
void xa_disable_delete_view_buttons (gboolean value);
void Update_StatusBar (gchar *msg);
_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits