file-roller r2196 - in trunk: . src



Author: paobac
Date: Sat Mar 29 16:48:25 2008
New Revision: 2196
URL: http://svn.gnome.org/viewvc/file-roller?rev=2196&view=rev

Log:
2008-03-29  Paolo Bacchilega  <paobac svn gnome org>

	* src/Makefile.am: 
	* src/gio-utils.h: 
	* src/gio-utils.c: 
	* src/fr-window.h: 
	* src/file-list.c:
	* src/file-list.h:
	* src/fr-archive.c: 
	* src/fr-archive.h: 
	
	Removed file-list.[ch].  Use the gio-utils functions to read a directory
	content asynchronously.

Removed:
   trunk/src/file-list.c
   trunk/src/file-list.h
Modified:
   trunk/ChangeLog
   trunk/src/Makefile.am
   trunk/src/fr-archive.c
   trunk/src/fr-archive.h
   trunk/src/fr-window.h
   trunk/src/gio-utils.c
   trunk/src/gio-utils.h

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Sat Mar 29 16:48:25 2008
@@ -63,8 +63,6 @@
 	eggtreemultidnd.h		\
 	file-data.c			\
 	file-data.h			\
-	file-list.c			\
-	file-list.h			\
 	file-utils.c			\
 	file-utils.h			\
 	fr-archive.c			\

Modified: trunk/src/fr-archive.c
==============================================================================
--- trunk/src/fr-archive.c	(original)
+++ trunk/src/fr-archive.c	Sat Mar 29 16:48:25 2008
@@ -33,10 +33,10 @@
 #include <libgnomevfs/gnome-vfs-ops.h>
 #include <libgnomevfs/gnome-vfs-async-ops.h>
 #include <libgnomevfs/gnome-vfs-utils.h>
-#include "file-data.h"
-#include "file-list.h"
-#include "file-utils.h"
 #include "glib-utils.h"
+#include "file-utils.h"
+#include "gio-utils.h"
+#include "file-data.h"
 #include "fr-archive.h"
 #include "fr-command.h"
 #include "fr-command-ace.h"
@@ -127,7 +127,9 @@
 							     * stoppable. */
 	gpointer             add_is_stoppable_data;
 	GnomeVFSAsyncHandle *xfer_handle;
-	VisitDirHandle      *vd_handle;
+/* FIXME
+  	VisitDirHandle      *vd_handle; */
+  	GCancellable        *cancellable;
 	char                *temp_dir;
 	gboolean             continue_adding_dropped_items;
 	DroppedItemsData    *dropped_items_data;
@@ -307,6 +309,7 @@
 		archive->priv->xfer_handle = NULL;
 	}
 
+/*FIXME
 	if (archive->priv->vd_handle != NULL) {
 		visit_dir_async_interrupt (archive->priv->vd_handle, NULL, NULL);
 		archive->priv->vd_handle = NULL;
@@ -316,6 +319,10 @@
 					     FR_PROC_ERROR_STOPPED,
 					     NULL);
 	}
+*/
+	
+	if (! g_cancellable_is_cancelled (archive->priv->cancellable)) 
+		g_cancellable_cancel (archive->priv->cancellable);
 }
 
 
@@ -377,7 +384,8 @@
 
 	archive->priv->extraction_destination = NULL;
 	archive->priv->temp_extraction_dir = NULL;
-
+	archive->priv->cancellable = g_cancellable_new ();
+	
 	archive->process = fr_process_new ();
 	g_signal_connect (G_OBJECT (archive->process),
 			  "sticky_only",
@@ -2106,46 +2114,12 @@
 }
 
 
-static void
-file_list_remove_from_pattern (GList      **list,
-			       const char  *pattern)
-{
-	char  **patterns;
-	GList  *scan;
-
-	if (pattern == NULL)
-		return;
-
-	patterns = search_util_get_patterns (pattern);
-
-	for (scan = *list; scan;) {
-		char *path = scan->data;
-		char *utf8_name;
-
-		utf8_name = g_filename_to_utf8 (file_name_from_path (path), -1, NULL, NULL, NULL);
-
-		if (match_patterns (patterns, utf8_name, 0)) {
-			*list = g_list_remove_link (*list, scan);
-			g_free (scan->data);
-			g_list_free (scan);
-			scan = *list;
-		} else
-			scan = scan->next;
-
-		g_free (utf8_name);
-	}
-
-	g_strfreev (patterns);
-}
-
-
 /* -- add with wildcard -- */
 
 
 typedef struct {
 	FrArchive     *archive;
-	char          *exclude_files;
-	char          *base_dir;
+	char          *source_dir;
 	char          *dest_dir;
 	gboolean       update;
 	char          *password;
@@ -2156,9 +2130,9 @@
 static void
 add_with_wildcard_data_free (AddWithWildcardData *aww_data)
 {
-	g_free (aww_data->base_dir);
+	g_free (aww_data->source_dir);
+	g_free (aww_data->dest_dir);
 	g_free (aww_data->password);
-	g_free (aww_data->exclude_files);
 	g_free (aww_data);
 }
 
@@ -2175,7 +2149,7 @@
 	if (error != NULL) {
 		fr_archive_action_completed (archive,
 					     FR_ACTION_GETTING_FILE_LIST, 
-					     FR_PROC_ERROR_GENERIC,
+					     (g_error_matches (error, G_FILE_ERROR, G_IO_ERROR_CANCELLED) ? FR_PROC_ERROR_STOPPED : FR_PROC_ERROR_GENERIC),
 					     error->message);
 		return;
 	}
@@ -2184,14 +2158,16 @@
 				     FR_ACTION_GETTING_FILE_LIST, 
 				     FR_PROC_ERROR_NONE,
 				     NULL);
+
+/* FIXME
 	visit_dir_handle_free (archive->priv->vd_handle);
 	archive->priv->vd_handle = NULL;
+*/
 
 	if (file_list != NULL) {
-		file_list_remove_from_pattern (&file_list, aww_data->exclude_files);
 		fr_archive_add_files (aww_data->archive,
 				      file_list,
-				      aww_data->base_dir,
+				      aww_data->source_dir,
 				      aww_data->dest_dir,
 				      aww_data->update,
 				      aww_data->password,
@@ -2208,7 +2184,7 @@
 fr_archive_add_with_wildcard (FrArchive     *archive,
 			      const char    *include_files,
 			      const char    *exclude_files,
-			      const char    *base_dir,
+			      const char    *source_dir,
 			      const char    *dest_dir,
 			      gboolean       update,
 			      gboolean       recursive,
@@ -2218,25 +2194,25 @@
 {
 	AddWithWildcardData *aww_data;
 
-	g_return_if_fail (archive->priv->vd_handle == NULL);
+	/* FIXME: g_return_if_fail (archive->priv->vd_handle == NULL); */
 	g_return_if_fail (! archive->read_only);
 
 	aww_data = g_new0 (AddWithWildcardData, 1);
 	aww_data->archive = archive;
-	aww_data->base_dir = g_strdup (base_dir);
+	aww_data->source_dir = g_strdup (source_dir);
 	aww_data->dest_dir = g_strdup (dest_dir);
 	aww_data->update = update;
 	aww_data->password = g_strdup (password);
 	aww_data->compression = compression;
-	aww_data->exclude_files = g_strdup (exclude_files);
 
 	g_signal_emit (G_OBJECT (archive),
 		       fr_archive_signals[START],
 		       0,
 		       FR_ACTION_GETTING_FILE_LIST);
 
+/*
 	archive->priv->vd_handle = get_wildcard_file_list_async (
-					base_dir,
+					source_dir,
 					include_files,
 					recursive,
 					follow_links,
@@ -2246,6 +2222,20 @@
 					IGNORE_CASE,
 					add_with_wildcard__step2,
 					aww_data);
+*/
+					
+	g_directory_list_async (source_dir, 
+				NULL,
+				recursive,
+				follow_links,
+				NO_BACKUP_FILES,
+				NO_DOT_FILES,
+				include_files,
+				exclude_files,
+				IGNORE_CASE,
+				archive->priv->cancellable,
+				add_with_wildcard__step2,
+				aww_data);
 }
 
 
@@ -2254,7 +2244,6 @@
 
 typedef struct {
 	FrArchive     *archive;
-	GList         *dir_list;
 	char          *base_dir;
 	char          *dest_dir;
 	gboolean       update;
@@ -2266,8 +2255,8 @@
 static void
 add_directory_data_free (AddDirectoryData *ad_data)
 {
-	path_list_free (ad_data->dir_list);
 	g_free (ad_data->base_dir);
+	g_free (ad_data->dest_dir);
 	g_free (ad_data->password);
 	g_free (ad_data);
 }
@@ -2282,13 +2271,15 @@
 	AddDirectoryData *ad_data = data;
 	FrArchive        *archive = ad_data->archive;
 
+/* FIXME:
 	visit_dir_handle_free (archive->priv->vd_handle);
 	archive->priv->vd_handle = NULL;
+*/
 
 	if (error != NULL) {
 		fr_archive_action_completed (archive,
 					     FR_ACTION_GETTING_FILE_LIST,
-					     FR_PROC_ERROR_GENERIC,
+					     (g_error_matches (error, G_FILE_ERROR, G_IO_ERROR_CANCELLED) ? FR_PROC_ERROR_STOPPED : FR_PROC_ERROR_GENERIC),
 					     error->message);
 		return;
 	}
@@ -2298,8 +2289,11 @@
 				     FR_PROC_ERROR_NONE,
 				     NULL);
 
-	if (archive->command->propAddCanStoreFolders)
+	if (archive->command->propAddCanStoreFolders) 
 		file_list = g_list_concat (file_list, dir_list);
+	else
+		path_list_free (dir_list);
+		
 	if (file_list != NULL) {
 		fr_archive_add_files (ad_data->archive,
 				      file_list,
@@ -2328,12 +2322,12 @@
 {
 	AddDirectoryData *ad_data;
 
-	g_return_if_fail (archive->priv->vd_handle == NULL);
+/* FIXME
+  	g_return_if_fail (archive->priv->vd_handle == NULL); */
 	g_return_if_fail (! archive->read_only);
 
 	ad_data = g_new0 (AddDirectoryData, 1);
 	ad_data->archive = archive;
-	ad_data->dir_list = g_list_prepend (NULL, g_strdup (directory));
 	ad_data->base_dir = g_strdup (base_dir);
 	ad_data->dest_dir = g_strdup (dest_dir);
 	ad_data->update = update;
@@ -2345,11 +2339,20 @@
 		       0,
 		       FR_ACTION_GETTING_FILE_LIST);
 
+/* FIXME:
 	archive->priv->vd_handle = get_items_file_list_async (
 					ad_data->dir_list,
 					base_dir,
 					add_directory__step2,
 					ad_data);
+*/
+			    
+	g_directory_list_all_async (directory, 
+				    base_dir,
+				    TRUE,
+				    archive->priv->cancellable,
+				    add_directory__step2,
+				    ad_data);
 }
 
 
@@ -2366,12 +2369,12 @@
 {
 	AddDirectoryData *ad_data;
 
-	g_return_if_fail (archive->priv->vd_handle == NULL);
+/* FIXME
+ 	g_return_if_fail (archive->priv->vd_handle == NULL); */
 	g_return_if_fail (! archive->read_only);
 
 	ad_data = g_new0 (AddDirectoryData, 1);
 	ad_data->archive = archive;
-	ad_data->dir_list = path_list_dup (item_list);
 	ad_data->base_dir = g_strdup (base_dir);
 	ad_data->dest_dir = g_strdup (dest_dir);
 	ad_data->update = update;
@@ -2383,11 +2386,19 @@
 		       0,
 		       FR_ACTION_GETTING_FILE_LIST);
 
+/* FIXME:
 	archive->priv->vd_handle = get_items_file_list_async (
 					ad_data->dir_list,
 					base_dir,
 					add_directory__step2,
 					ad_data);
+*/
+				
+	g_list_items_async (item_list,
+			    base_dir,
+			    archive->priv->cancellable,
+			    add_directory__step2,
+			    ad_data);
 }
 
 

Modified: trunk/src/fr-archive.h
==============================================================================
--- trunk/src/fr-archive.h	(original)
+++ trunk/src/fr-archive.h	Sat Mar 29 16:48:25 2008
@@ -26,7 +26,6 @@
 #include <glib.h>
 #include "fr-process.h"
 #include "fr-command.h"
-#include "file-list.h"
 
 #define FR_TYPE_ARCHIVE            (fr_archive_get_type ())
 #define FR_ARCHIVE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), FR_TYPE_ARCHIVE, FrArchive))

Modified: trunk/src/fr-window.h
==============================================================================
--- trunk/src/fr-window.h	(original)
+++ trunk/src/fr-window.h	Sat Mar 29 16:48:25 2008
@@ -27,7 +27,6 @@
 #include <libgnomeui/libgnomeui.h>
 #include <libgnomevfs/gnome-vfs-mime-handlers.h>
 #include "typedefs.h"
-#include "file-list.h"
 #include "fr-archive.h"
 
 #define GCONF_NOTIFICATIONS 10

Modified: trunk/src/gio-utils.c
==============================================================================
--- trunk/src/gio-utils.c	(original)
+++ trunk/src/gio-utils.c	Sat Mar 29 16:48:25 2008
@@ -182,7 +182,6 @@
 	GFile                *current;
 	GHashTable           *already_visited;
 	GList                *to_visit;
-	Filter               *filter;
 	GCancellable         *cancellable;
 	GFileEnumerator      *enumerator;
 	GError               *error;	
@@ -202,8 +201,6 @@
 		g_hash_table_destroy (fec->already_visited);
 	if (fec->to_visit != NULL)
 		path_list_free (fec->to_visit);
-	if (fec->filter)
-		filter_destroy (fec->filter);
 	if (fec->error != NULL)
 		g_error_free (fec->error);
 	g_free (fec);
@@ -525,7 +522,9 @@
 
 	/* Always include the base directory, this way empty base 
  	 * directories are added to the archive as well.  */
-		 
+	
+	h_dirs = g_hash_table_new (g_str_hash, g_str_equal);
+	
 	dir = g_strdup (gfl->base_dir);
 	gfl->dirs = g_list_prepend (gfl->dirs, dir);
 	g_hash_table_insert (h_dirs, dir, GINT_TO_POINTER (1));
@@ -749,7 +748,8 @@
 			gfl->files = g_list_prepend (gfl->files, rel_path);
 		}
 	}
-		
+	
+	gfl->current_dir = gfl->to_visit;
 	get_items_for_current_dir (gfl);
 }
 
@@ -956,19 +956,19 @@
 
 typedef struct {
 	char      *uri;
-	GFileType  type;
+	GFileInfo *info;
 } ChildData;
 
 
 static ChildData*
 child_data_new (const char *uri,
-		GFileType   type)
+		GFileInfo  *info)
 {
 	ChildData *data;
 	
 	data = g_new0 (ChildData, 1);
 	data->uri = g_strdup (uri);
-	data->type = type;
+	data->info = g_file_info_dup (info);
 	
 	return data;
 }
@@ -980,6 +980,7 @@
 	if (child == NULL)
 		return;
 	g_free (child->uri);
+	g_object_unref (child->info);
 	g_free (child);
 }
 
@@ -1118,7 +1119,7 @@
 
 	child = dcd->current->data;
 	dcd->current_destination = get_destination_for_uri (dcd, child->uri);
-	switch (child->type) {
+	switch (g_file_info_get_file_type (child->info)) {
 	case G_FILE_TYPE_DIRECTORY:	
 		/* FIXME: how to make a directory asynchronously ? */
 		if (! g_file_make_directory (destination, dcd->cancellable, &(dcd->error))) {
@@ -1126,6 +1127,13 @@
 			return;
 		}
 		break;
+	case G_FILE_TYPE_SYMBOLIC_LINK:
+		/* FIXME: how to make a link asynchronously ? */
+		if (! g_file_make_symbolic_link (destination, g_file_info_get_symlink_target (child->info), dcd->cancellable, &(dcd->error))) {
+			g_directory_copy_done (dcd, dcd->error);
+			return;
+		}
+		break;
 	case G_FILE_TYPE_REGULAR:
 		dcd->current_source = g_file_new_for_uri (child->uri);
 		g_file_copy_async (source,
@@ -1170,7 +1178,7 @@
 {
 	DirectoryCopyData *dcd = user_data;
 	 
-	dcd->to_copy = g_list_prepend (dcd->to_copy, child_data_new (uri, g_file_info_get_file_type (info)));
+	dcd->to_copy = g_list_prepend (dcd->to_copy, child_data_new (uri, info));
 	dcd->tot_files++;
 }
 
@@ -1181,8 +1189,13 @@
 			    gpointer     user_data)
 {	
 	DirectoryCopyData *dcd = user_data;
+	GFileInfo         *info;
+	
+	info = g_file_info_new ();
+	g_file_info_set_file_type (info, G_FILE_TYPE_DIRECTORY);
+	dcd->to_copy = g_list_prepend (dcd->to_copy, child_data_new (uri, info));
+	g_object_unref (info);
 	
-	dcd->to_copy = g_list_prepend (dcd->to_copy, child_data_new (uri, G_FILE_TYPE_DIRECTORY));
 	return TRUE;
 }
 
@@ -1199,6 +1212,7 @@
 			gpointer               user_data)
 {
 	DirectoryCopyData *dcd;
+	GFileInfo         *info;
 	
 	dcd = g_new0 (DirectoryCopyData, 1);
 	dcd->source = g_file_dup (source);
@@ -1214,7 +1228,10 @@
 	dcd->source_uri = g_file_get_uri (dcd->source);
 	dcd->destination_uri = g_file_get_uri (dcd->destination);	
 	
-	dcd->to_copy = g_list_prepend (NULL, child_data_new (dcd->source_uri, G_FILE_TYPE_DIRECTORY));
+	info = g_file_info_new ();
+	g_file_info_set_file_type (info, G_FILE_TYPE_DIRECTORY);
+	dcd->to_copy = g_list_prepend (NULL, child_data_new (dcd->source_uri, info));
+	g_object_unref (info);
 	
 	g_directory_foreach_child (dcd->source_uri,
 			           TRUE,
@@ -1225,4 +1242,3 @@
 			           g_directory_copy_list_ready,
 			           dcd);
 }
-

Modified: trunk/src/gio-utils.h
==============================================================================
--- trunk/src/gio-utils.h	(original)
+++ trunk/src/gio-utils.h	Sat Mar 29 16:48:25 2008
@@ -118,15 +118,8 @@
  * @done_func:
  * @done_data:
  * 
- * Inserts a #GNode as the last child of the given parent.
- *
  */
-#define g_directory_list_all_async(directory, \
-				   base_dir, \
-				   recursive, \
-				   cancellable, \
-				   done_func, \
-				   done_data)	g_directory_list_async ((directory), (base_dir), (recursive), TRUE, FALSE, FALSE, NULL, NULL, FALSE, (cancellable), (done_func), (done_data))
+#define g_directory_list_all_async(directory, base_dir, recursive, cancellable, done_func, done_data) \
+    g_directory_list_async ((directory), (base_dir), (recursive), TRUE, FALSE, FALSE, NULL, NULL, FALSE, (cancellable), (done_func), (done_data))
 
 #endif /* _GIO_UTILS_H */
-



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]