file-roller r2215 - in trunk: . src



Author: paobac
Date: Sun Apr  6 12:21:25 2008
New Revision: 2215
URL: http://svn.gnome.org/viewvc/file-roller?rev=2215&view=rev

Log:
2008-04-06  Paolo Bacchilega  <paobac svn gnome org>

	* src/open-file.c: 
	* src/main.c: 
	* src/glib-utils.h: 
	* src/glib-utils.c: 
	* src/fr-window.c: 
	* src/fr-command-tar.c: 
	* src/fr-command-iso.c: 
	* src/fr-command.h: 
	* src/fr-command.c: 
	* src/fr-archive.h: 
	* src/fr-archive.c: 
	* src/file-utils.h: 
	* src/file-utils.c: 
	* src/file-data.h: 
	* src/file-data.c: 
	* src/dlg-open-with.c: 
	* src/dlg-add-folder.c: 

	Started fixing regression bugs due to the GIO port.

Modified:
   trunk/ChangeLog
   trunk/src/dlg-add-folder.c
   trunk/src/dlg-open-with.c
   trunk/src/file-data.c
   trunk/src/file-data.h
   trunk/src/file-utils.c
   trunk/src/file-utils.h
   trunk/src/fr-archive.c
   trunk/src/fr-archive.h
   trunk/src/fr-command-iso.c
   trunk/src/fr-command-tar.c
   trunk/src/fr-command.c
   trunk/src/fr-command.h
   trunk/src/fr-window.c
   trunk/src/glib-utils.c
   trunk/src/glib-utils.h
   trunk/src/main.c
   trunk/src/open-file.c

Modified: trunk/src/dlg-add-folder.c
==============================================================================
--- trunk/src/dlg-add-folder.c	(original)
+++ trunk/src/dlg-add-folder.c	Sun Apr  6 12:21:25 2008
@@ -162,7 +162,7 @@
 					 fr_window_get_current_location (window),
 					 file_name_from_path (folder),
 					 NULL);
-		dest_dir = get_local_path_from_uri (dest_uri);
+		dest_dir = g_filename_from_uri (dest_uri, NULL, NULL);
 
 		fr_window_archive_add_with_wildcard (window,
 						     include_files,

Modified: trunk/src/dlg-open-with.c
==============================================================================
--- trunk/src/dlg-open-with.c	(original)
+++ trunk/src/dlg-open-with.c	Sun Apr  6 12:21:25 2008
@@ -363,7 +363,7 @@
 		const char *mime_type;
 		const char *name = scan->data;
 
-		mime_type = get_file_mime_type (name, FALSE);
+		mime_type = get_file_mime_type_for_path (name, FALSE);
 		if ((mime_type != NULL) && ! g_content_type_is_unknown (mime_type))
 			data->app_list = g_list_concat (data->app_list, g_app_info_get_all_for_type (mime_type));
 	}

Modified: trunk/src/file-data.c
==============================================================================
--- trunk/src/file-data.c	(original)
+++ trunk/src/file-data.c	Sun Apr  6 12:21:25 2008
@@ -23,8 +23,9 @@
 #include <config.h>
 #include <glib/gi18n.h>
 #include <gio/gio.h>
-#include "file-data.h"
+#include "glib-utils.h"
 #include "file-utils.h"
+#include "file-data.h"
 
 
 FileData *
@@ -97,28 +98,14 @@
 }
 
 
-static void
-file_data_update_content_type (FileData *fdata,
-			       gboolean  fast_file_type)
-{
-	GFile      *file;
-	GFileInfo  *info;
-	GError     *error = NULL;
+void
+file_data_update_content_type (FileData *fdata)
+{
 	
-	file = g_file_new_for_path (fdata->full_path);
-	info = g_file_query_info (file, 
-				  fast_file_type ?
-				  G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE :
-				  G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
-				  0, NULL, &error);
-	if (error != NULL) {
-		g_warning ("could not get the content type: %s\n", error->message);
-		g_clear_error (&error);
-	}
-	else
-		fdata->content_type = g_file_info_get_content_type (info);
-
-	g_object_unref (file);
+	if (fdata->dir) 
+		fdata->content_type = MIME_TYPE_DIRECTORY;
+	else 
+		fdata->content_type = get_static_string (g_content_type_guess (fdata->full_path, NULL, 0, NULL));
 }
 
 

Modified: trunk/src/file-data.h
==============================================================================
--- trunk/src/file-data.h	(original)
+++ trunk/src/file-data.h	Sun Apr  6 12:21:25 2008
@@ -55,10 +55,11 @@
 
 #define FR_TYPE_FILE_DATA (file_data_get_type ())
 
-GType           file_data_get_type      (void);
-FileData *      file_data_new           (void);
-FileData *      file_data_copy          (FileData *src);
-void            file_data_free          (FileData *fdata);
-gboolean        file_data_is_dir        (FileData *fdata);
+GType           file_data_get_type            (void);
+FileData *      file_data_new                 (void);
+FileData *      file_data_copy                (FileData *src);
+void            file_data_free                (FileData *fdata);
+void            file_data_update_content_type (FileData *fdata);
+gboolean        file_data_is_dir              (FileData *fdata);
 
 #endif /* FILE_DATA_H */

Modified: trunk/src/file-utils.c
==============================================================================
--- trunk/src/file-utils.c	(original)
+++ trunk/src/file-utils.c	Sun Apr  6 12:21:25 2008
@@ -110,6 +110,26 @@
 
 
 gboolean
+path_is_dir (const char *path)
+{
+	char     *uri;
+	gboolean  result;
+	
+	uri = g_filename_to_uri (path, NULL, NULL);
+	result = uri_is_dir (uri);
+	g_free (uri);
+	
+	return result;
+}
+
+gboolean
+uri_is_local (const char  *uri)
+{
+	return strncmp (uri, "file://", 7) == 0; 
+}
+
+
+gboolean
 dir_is_empty (const char *uri)
 {
 	GFile           *file;
@@ -304,6 +324,8 @@
 
 	g_object_unref (info);
 	g_object_unref (file);
+	
+	return size;
 }
 
 
@@ -325,7 +347,7 @@
 		result = (time_t) g_file_info_get_attribute_uint64 (info, type);
 	}
 	else {
-		g_warning ("Failed to get %s for %s: %s", type, uri, err->message);
+		g_warning ("Failed to get %s: %s", type, err->message);
 		g_error_free (err);
 		result = 0;		
 	}		
@@ -580,16 +602,36 @@
 				  G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE :
 				  G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
 				  0, NULL, &err);
-
-	result = g_file_info_get_content_type (info);
-
-	g_object_unref (info);
+	if (info == NULL) {
+		g_warning ("could not get content type for %s: %s", filename, err->message);
+		g_clear_error (&err);
+	}
+	else {
+		result = get_static_string (g_file_info_get_content_type (info));
+		g_object_unref (info);
+	}
+	
 	g_object_unref (file);
 
 	return result;
 }
 
 
+const char*
+get_file_mime_type_for_path (const char  *filename,
+                    	     gboolean     fast_file_type)
+{
+	char       *uri;
+	const char *mime_type;
+	
+	uri = g_filename_to_uri (filename, NULL, NULL);
+	mime_type = get_file_mime_type (uri, fast_file_type);
+	g_free (uri);
+	
+	return mime_type;
+}
+
+
 void
 path_list_free (GList *path_list)
 {
@@ -644,6 +686,9 @@
 	GFileInfo       *info;
 	gboolean         error_occurred = FALSE;
 	
+	if (error != NULL)
+		*error = NULL;
+	
 	file_enum = g_file_enumerate_children (dir, 
 					       G_FILE_ATTRIBUTE_STANDARD_NAME "," 
 					       G_FILE_ATTRIBUTE_STANDARD_TYPE,
@@ -651,9 +696,8 @@
 
 	uri = g_file_get_uri (dir);
 	while (! error_occurred && (info = g_file_enumerator_next_file (file_enum, NULL, error)) != NULL) {
-		const char *name;
-		char       *child_uri;
-		GFile      *child;
+		char  *child_uri;
+		GFile *child;
 		
 		child_uri = g_build_path ("/", uri, g_file_info_get_name (info), NULL);
 		child = g_file_new_for_uri (child_uri);
@@ -671,6 +715,7 @@
 		
 		g_object_unref (child);
 		g_free (child_uri);
+		g_object_unref (info);
 	}
 	g_free (uri);
 	
@@ -692,7 +737,7 @@
 	
 	dir = g_file_new_for_uri (uri);
 	result = delete_directory_recursive (dir, &error);
-	if (error != NULL) {
+	if (! result) {
 		g_warning ("Cannot delete %s: %s", uri, error->message);
 		g_clear_error (&error);
 	}
@@ -708,7 +753,7 @@
 	char     *uri;
 	gboolean  result;
 	
-	uri = get_uri_from_local_path (path);
+	uri = g_filename_to_uri (path, NULL, NULL);
 	result = remove_directory (uri);
 	g_free (uri);
 	

Modified: trunk/src/file-utils.h
==============================================================================
--- trunk/src/file-utils.h	(original)
+++ trunk/src/file-utils.h	Sun Apr  6 12:21:25 2008
@@ -27,6 +27,8 @@
 #include <time.h>
 #include <gio/gio.h>
 
+#define MIME_TYPE_DIRECTORY "application/directory-normal"
+#define MIME_TYPE_ARCHIVE "application/x-archive"
 
 #define get_home_relative_dir(x)        \
 	g_strconcat (g_get_home_dir (), \
@@ -37,6 +39,8 @@
 gboolean            uri_exists                   (const char  *uri);
 gboolean            uri_is_file                  (const char  *uri);
 gboolean            uri_is_dir                   (const char  *uri);
+gboolean            path_is_dir                  (const char  *path);
+gboolean            uri_is_local                 (const char  *uri);
 gboolean            dir_is_empty                 (const char  *uri);
 gboolean            dir_contains_one_object      (const char  *uri);
 char *              get_dir_content_if_unique    (const char  *uri);
@@ -61,7 +65,9 @@
 						  const char  *ext);
 gboolean            is_mime_type                 (const char  *type,
 						  const char  *pattern);
-const char*         get_file_mime_type           (const char  *filename,
+const char*         get_file_mime_type           (const char  *uri,
+                    				  gboolean     fast_file_type);
+const char*         get_file_mime_type_for_path  (const char  *filename,
                     				  gboolean     fast_file_type);
 guint64             get_dest_free_space          (const char  *path);
 gboolean            remove_directory             (const char  *uri);

Modified: trunk/src/fr-archive.c
==============================================================================
--- trunk/src/fr-archive.c	(original)
+++ trunk/src/fr-archive.c	Sun Apr  6 12:21:25 2008
@@ -494,77 +494,101 @@
 /* filename must not be escaped. */
 static gboolean
 create_command_from_mime_type (FrArchive  *archive,
-			       const char *filename,
 			       const char *mime_type)
 {
+	char *filename;
+	
 	archive->is_compressed_file = FALSE;
 
+	filename = g_file_get_path (archive->local_copy);
 	if (is_mime_type (mime_type, "application/x-tar")) {
 		archive->command = fr_command_tar_new (archive->process,
 						       filename,
 						       FR_COMPRESS_PROGRAM_NONE);
-	} else if (is_mime_type (mime_type, "application/x-compressed-tar")) {
+	} 
+	else if (is_mime_type (mime_type, "application/x-compressed-tar")) {
 		archive->command = fr_command_tar_new (archive->process,
 						       filename,
 						       FR_COMPRESS_PROGRAM_GZIP);
-	} else if (is_mime_type (mime_type, "application/x-bzip-compressed-tar")) {
+	} 
+	else if (is_mime_type (mime_type, "application/x-bzip-compressed-tar")) {
 		archive->command = fr_command_tar_new (archive->process,
 						       filename,
 						       FR_COMPRESS_PROGRAM_BZIP2);
-	} else if (is_mime_type (mime_type, "application/zip") ||
+	} 
+	else if (is_mime_type (mime_type, "application/zip") ||
 		   is_mime_type (mime_type, "application/x-zip") ||
 		   is_mime_type (mime_type, "application/octet-stream")) {
 		archive->command = fr_command_zip_new (archive->process,
 						       filename);
-	} else if (is_mime_type (mime_type, "application/x-zoo")) {
+	} 
+	else if (is_mime_type (mime_type, "application/x-zoo")) {
 		archive->command = fr_command_zoo_new (archive->process,
 						       filename);
-	} else if (is_mime_type (mime_type, "application/x-rar")) {
+	} 
+	else if (is_mime_type (mime_type, "application/x-rar")) {
 		archive->command = fr_command_rar_new (archive->process,
 						       filename);
-	} else if (is_mime_type (mime_type, "application/x-arj")) {
+	} 
+	else if (is_mime_type (mime_type, "application/x-arj")) {
 		archive->command = fr_command_arj_new (archive->process,
 						       filename);
-	} else if (is_mime_type (mime_type, "application/x-stuffit")) {
+	} 
+	else if (is_mime_type (mime_type, "application/x-stuffit")) {
 		archive->command = fr_command_unstuff_new (archive->process,
 							   filename);
-	} else if (is_mime_type (mime_type, "application/x-rpm")) {
+	} 
+	else if (is_mime_type (mime_type, "application/x-rpm")) {
 		archive->command = fr_command_rpm_new (archive->process,
 						       filename);
-	} else if (is_mime_type (mime_type, "application/x-cd-image")) {
+	} 
+	else if (is_mime_type (mime_type, "application/x-cd-image")) {
 		archive->command = fr_command_iso_new (archive->process,
 						       filename);
-	} else if (is_mime_type (mime_type, "application/x-deb") ||
+	} 
+	else if (is_mime_type (mime_type, "application/x-deb") ||
 		   is_mime_type (mime_type, "application/x-ar")) {
 		archive->command = fr_command_ar_new (archive->process,
 						      filename);
-	} else if (is_mime_type (mime_type, "application/x-ace")) {
+	} 
+	else if (is_mime_type (mime_type, "application/x-ace")) {
 		archive->command = fr_command_ace_new (archive->process,
 						       filename);
-	} else if (is_mime_type (mime_type, "application/x-7zip")) {
+	} 
+	else if (is_mime_type (mime_type, "application/x-7zip")) {
 		archive->command = fr_command_7z_new (archive->process,
 						      filename);
-	} else if (is_mime_type (mime_type, "application/x-cpio")) {
+	} 
+	else if (is_mime_type (mime_type, "application/x-cpio")) {
 		archive->command = fr_command_cpio_new (archive->process,
 							filename);
-	} else
-		return FALSE;
-
+	} 
+	g_free (filename);
+	
 	return (archive->command != NULL);
 }
 
 
-/* filename must not be escaped. */
 static const char *
-get_mime_type_from_content (const char *filename)
+get_mime_type_from_content (GFile *file)
 {
-	const char *mime_type;
-
-	mime_type = get_file_mime_type (filename, FALSE);
-	if (g_content_type_is_unknown (mime_type))
-		return NULL;
-
-	return mime_type;
+	GFileInfo  *info;
+	GError     *err = NULL;
+ 	const char *content_type = NULL;
+	
+	info = g_file_query_info (file, 
+				  G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+				  0, NULL, &err);
+	if (info == NULL) {
+		g_warning ("could not get content type: %s", err->message);
+		g_clear_error (&err);
+	}
+	else {
+		content_type = get_static_string (g_file_info_get_content_type (info));
+		g_object_unref (info);
+	}
+	
+	return content_type;
 }
 
 
@@ -585,7 +609,7 @@
 
 /* filename must not be escaped. */
 static const char *
-get_mime_type_from_sniffer (const char *filename)
+get_mime_type_from_sniffer (GFile *file)
 {
 	static struct {
 		const char *mime_type;
@@ -599,23 +623,29 @@
 		 */
 		{ NULL, NULL, 0 }
 	};
-	FILE        *file;
-	char         buffer[5];
-	int          n, i;
+	char  *filename;
+	FILE  *f;
+	char   buffer[5];
+	int    n, i;
 
-	file = fopen (filename, "rb");
-
-	if (file == NULL)
+	if (! g_file_has_uri_scheme (file, "file"))
 		return NULL;
 
-	if (file_extension_is (filename, ".jar"))
+	filename = g_file_get_path (file);
+	if (file_extension_is (filename, ".jar")) {
+		g_free (filename);
+		return NULL;
+	}
+		
+	f = fopen (filename, "rb");
+	g_free (filename);
+	
+	if (f == NULL)
 		return NULL;
 
-	n = fread (buffer, sizeof (char), sizeof (buffer) - 1, file);
+	n = fread (buffer, sizeof (char), sizeof (buffer) - 1, f);
+	fclose (f);
 	buffer[n] = 0;
-
-	fclose (file);
-
 	for (i = 0; sniffer_data[i].mime_type != NULL; i++) {
 		const char *first_bytes = sniffer_data[i].first_bytes;
 		int         len         = sniffer_data[i].len;
@@ -635,9 +665,9 @@
 {
 	char *filename;
 	
-	filename = g_file_get_path (archive->local_copy);
 	archive->is_compressed_file = FALSE;
 	
+	filename = g_file_get_path (archive->local_copy);
 	if (file_extension_is (filename, ".tar.gz")
 	    || file_extension_is (filename, ".tgz")) 
 	{
@@ -777,7 +807,6 @@
 			}
 		}
 	}
-	
 	g_free (filename);
 	
 	return (archive->command != NULL);
@@ -986,7 +1015,7 @@
 {
 	char *temp_extraction_dir;
 	
-	temp_extraction_dir = get_uri_from_local_path (archive->priv->temp_extraction_dir);
+	temp_extraction_dir = g_filename_to_uri (archive->priv->temp_extraction_dir, NULL, NULL);
 	g_directory_copy_async (temp_extraction_dir,
 				archive->priv->extraction_destination,
 				G_FILE_COPY_OVERWRITE,
@@ -1120,8 +1149,10 @@
 		return FALSE;
 	}
 
-	if (tmp_command != NULL)
+	if (tmp_command != NULL) {
+		g_signal_handlers_disconnect_by_data (tmp_command, archive);
 		g_object_unref (G_OBJECT (tmp_command));
+	}
 
 	archive->read_only = FALSE;
 
@@ -1175,7 +1206,6 @@
 		    const char *password)
 {
 	FrCommand  *tmp_command;
-	char       *filename;
 	const char *mime_type = NULL;
 
 	archive->read_only = ! check_permissions (uri, W_OK);
@@ -1183,31 +1213,26 @@
 	/* find mime type */
 
 	tmp_command = archive->command;
-
-	filename = g_file_get_path (archive->local_copy);
-	mime_type = get_mime_type_from_sniffer (filename);
+	mime_type = get_mime_type_from_sniffer (archive->local_copy);
 	if (mime_type == NULL)
-		mime_type = get_mime_type_from_content (filename);
-	if ((mime_type == NULL) || ! create_command_from_mime_type (archive, filename, mime_type)) {
+		mime_type = get_mime_type_from_content (archive->local_copy);
+	if ((mime_type == NULL) || ! create_command_from_mime_type (archive, mime_type)) {
 		if (! create_command_from_filename (archive, TRUE)) {
 			archive->command = tmp_command;
 			fr_archive_action_completed (archive,
 						     FR_ACTION_LOADING_ARCHIVE, 
 						     FR_PROC_ERROR_GENERIC,
 						     _("Archive type not supported."));
-			g_free (filename);
 			return;
 		}
 	}
-	g_free (filename);
-
-	archive->content_type = mime_type;
-
 	if (tmp_command != NULL) {
 		g_signal_handlers_disconnect_by_data (tmp_command, archive);
 		g_object_unref (tmp_command);
 	}
 
+	archive->content_type = mime_type;
+
 	if ((archive->command->file_type == FR_FILE_TYPE_ZIP)
 	    && (! is_program_in_path ("zip")))
 		archive->read_only = TRUE;
@@ -1283,7 +1308,7 @@
 	XferData *xfer_data = user_data;
 	
 	g_source_remove (xfer_data->source_id);
-	copy_remote_file_done (NULL, (XferData *)user_data);
+	copy_remote_file_done (NULL, xfer_data);
 	return FALSE;
 }
 
@@ -1556,7 +1581,7 @@
 		char *uri = scan->data;
 		char *local_filename;
 		
-		local_filename = get_local_path_from_uri (uri);
+		local_filename = g_uri_unescape_string (uri, NULL);
 		if (local_filename != NULL)
 			local_file_list = g_list_prepend (local_file_list, local_filename);
 	}
@@ -1881,7 +1906,7 @@
 		      FRCompression  compression)
 {
 	if (uri_is_local (base_dir)) {
-		char *local_dir = get_local_path_from_uri (base_dir);
+		char *local_dir = g_filename_from_uri (base_dir, NULL, NULL);
 		fr_archive_add_local_files (archive,
 					    file_list, 
 					    local_dir, 
@@ -2839,7 +2864,6 @@
 			     gboolean    junk_paths,
 			     const char *password)
 {
-	char     *dest_dir;
 	GList    *filtered, *e_filtered;
 	GList    *scan;
 	gboolean  extract_all;
@@ -2849,8 +2873,6 @@
 
 	g_return_if_fail (archive != NULL);
 
-	dest_dir = get_local_path_from_uri (destination);
-
 	fr_archive_stoppable (archive, TRUE);
 
 	/* if a command supports all the requested options use
@@ -2868,7 +2890,7 @@
 		file_list_created = TRUE;
 	}
 
-	fr_command_set_n_files (command, g_list_length (file_list));
+	fr_command_set_n_files (archive->command, g_list_length (file_list));
 
 	use_base_dir = ! ((base_dir == NULL)
 			  || (strcmp (base_dir, "") == 0)
@@ -2902,7 +2924,7 @@
 			e_filtered = escape_file_list (archive->command, filtered);
 			extract_in_chunks (archive->command,
 					   e_filtered,
-					   dest_dir,
+					   destination,
 					   overwrite,
 					   skip_older,
 					   junk_paths,
@@ -2961,11 +2983,11 @@
 		else
 			filename = file_name_from_path (archive_list_filename);
 
-		if ((dest_dir[strlen (dest_dir) - 1] == '/')
+		if ((destination[strlen (destination) - 1] == '/')
 		    || (filename[0] == '/'))
-			sprintf (dest_filename, "%s%s", dest_dir, filename);
+			sprintf (dest_filename, "%s%s", destination, filename);
 		else
-			sprintf (dest_filename, "%s/%s", dest_dir, filename);
+			sprintf (dest_filename, "%s/%s", destination, filename);
 
 		debug (DEBUG_INFO, "-> %s\n", dest_filename);
 
@@ -2989,7 +3011,6 @@
 		/* all files got filtered, do nothing. */
 		debug (DEBUG_INFO, "All files got filtered, nothing to do.\n");
 
-		g_free (dest_dir);
 		if (extract_all)
 			path_list_free (file_list);
 		return;
@@ -3019,7 +3040,7 @@
 		move_files_in_chunks (archive,
 				      filtered,
 				      temp_dir,
-				      dest_dir);
+				      destination);
 
 		/* remove the temp dir. */
 
@@ -3035,7 +3056,7 @@
 	else
 		extract_in_chunks (archive->command,
 				   e_filtered,
-				   dest_dir,
+				   destination,
 				   overwrite,
 				   skip_older,
 				   junk_paths,
@@ -3046,7 +3067,6 @@
 		g_list_free (filtered);
 	if (file_list_created)
 		path_list_free (file_list);
-	g_free (dest_dir);
 }
 
 
@@ -3067,7 +3087,6 @@
 	archive->priv->temp_extraction_dir = NULL;
 
 	archive->priv->remote_extraction = ! uri_is_local (destination);
-
 	if (archive->priv->remote_extraction) {
  		archive->priv->temp_extraction_dir = get_temp_work_dir ();
 		fr_archive_extract_to_local (archive,
@@ -3079,15 +3098,20 @@
 				  	     junk_paths,
 				  	     password);
 	}
-	else 
+	else {
+		char *local_destination;
+		
+		local_destination = g_filename_from_uri (destination, NULL, NULL);
 		fr_archive_extract_to_local (archive,
 					     file_list,
-					     destination,
+					     local_destination,
 					     base_dir,
 					     skip_older,
 					     overwrite,
 					     junk_paths,
 					     password);
+		g_free (local_destination);
+	}
 }
 
 
@@ -3276,15 +3300,24 @@
 gboolean
 fr_archive_utils__file_is_archive (const char *filename)
 {
+	GFile      *file;
 	const char *mime_type;
 
-	mime_type = get_mime_type_from_content (filename);
-	if (mime_type == NULL)
-		return FALSE;
-
-	mime_type = get_mime_type_from_sniffer (filename);
-	if (mime_type != NULL)
+	file = g_file_new_for_uri (filename);
+	
+	mime_type = get_mime_type_from_sniffer (file);
+	if (mime_type != NULL) {
+		g_object_unref (file);
+		return TRUE;
+	}
+		
+	mime_type = get_mime_type_from_content (file);
+	if (mime_type != NULL) {
+		g_object_unref (file);
 		return TRUE;
+	}
+	
+	g_object_unref (file);
 
 	return fr_archive_utils__get_file_name_ext (filename) != NULL;
 }

Modified: trunk/src/fr-archive.h
==============================================================================
--- trunk/src/fr-archive.h	(original)
+++ trunk/src/fr-archive.h	Sun Apr  6 12:21:25 2008
@@ -124,7 +124,15 @@
 						  FRCompression  compression);
 void        fr_archive_extract                   (FrArchive     *archive,
 						  GList         *file_list,
-						  const char    *dest_dir,
+						  const char    *dest_uri,
+						  const char    *base_dir,
+						  gboolean       skip_older,
+						  gboolean       overwrite,
+						  gboolean       junk_path,
+						  const char    *password);
+void        fr_archive_extract_to_local          (FrArchive     *archive,
+						  GList         *file_list,
+						  const char    *dest_path,
 						  const char    *base_dir,
 						  gboolean       skip_older,
 						  gboolean       overwrite,

Modified: trunk/src/fr-command-iso.c
==============================================================================
--- trunk/src/fr-command-iso.c	(original)
+++ trunk/src/fr-command-iso.c	Sun Apr  6 12:21:25 2008
@@ -191,7 +191,7 @@
 			continue;
 
 		temp_dest_dir = unescape_str (e_temp_dest_dir);
-		temp_dest_dir_uri = get_uri_from_local_path (temp_dest_dir);
+		temp_dest_dir_uri = g_filename_to_uri (temp_dest_dir, NULL, NULL);
 		ensure_dir_exists (temp_dest_dir_uri, 0700, NULL);
 
 		fr_process_begin_command (comm->process, "sh " PRIVEXECDIR "isoinfo.sh");

Modified: trunk/src/fr-command-tar.c
==============================================================================
--- trunk/src/fr-command-tar.c	(original)
+++ trunk/src/fr-command-tar.c	Sun Apr  6 12:21:25 2008
@@ -722,7 +722,7 @@
 	}
 
 	{
-		char *uri = get_uri_from_local_path (comm->filename);
+		char *uri = g_filename_to_uri (comm->filename, NULL, NULL);
 		archive_exists = uri_exists (uri);
 		g_free (uri);
 	}

Modified: trunk/src/fr-command.c
==============================================================================
--- trunk/src/fr-command.c	(original)
+++ trunk/src/fr-command.c	Sun Apr  6 12:21:25 2008
@@ -532,6 +532,7 @@
 fr_command_add_file (FrCommand *comm,
 		     FileData  *fdata)
 {
+	file_data_update_content_type (fdata);
 	g_ptr_array_add (comm->files, fdata);
 }
 

Modified: trunk/src/fr-command.h
==============================================================================
--- trunk/src/fr-command.h	(original)
+++ trunk/src/fr-command.h	Sun Apr  6 12:21:25 2008
@@ -93,7 +93,7 @@
 	FrProcess  *process;         /* the process object used to execute
 				      * commands. */
 	FRAction    action;          /* current action. */
-	char       *filename;        /* archive filename. */
+	char       *filename;        /* archive file path. */
 	char       *e_filename;      /* escaped archive filename. */
 
 	gboolean    fake_load;       /* if TRUE does nothing when the list

Modified: trunk/src/fr-window.c
==============================================================================
--- trunk/src/fr-window.c	(original)
+++ trunk/src/fr-window.c	Sun Apr  6 12:21:25 2008
@@ -77,8 +77,6 @@
 #define DEF_WIN_HEIGHT 480
 #define DEF_SIDEBAR_WIDTH 200
 
-#define MIME_TYPE_DIRECTORY "application/directory-normal"
-#define MIME_TYPE_ARCHIVE "application/x-archive"
 #define ICON_TYPE_DIRECTORY "gnome-fs-directory"
 #define ICON_TYPE_REGULAR   "gnome-fs-regular"
 #define FILE_LIST_ICON_SIZE GTK_ICON_SIZE_LARGE_TOOLBAR
@@ -590,6 +588,8 @@
 {
 	FrWindow *window = FR_WINDOW (object);
 
+	fr_window_free_open_files (window);
+
 	if (window->archive != NULL) {
 		g_object_unref (window->archive);
 		window->archive = NULL;
@@ -5442,25 +5442,7 @@
 	fr_window_archive_close (window);
 
 	g_free (window->priv->archive_uri);
-	if (! uri_has_scheme (uri)) {
-		char *path;
-		
-		if (! g_path_is_absolute (uri)) {
-			char *current_dir;
-			
-			current_dir = g_get_current_dir ();
-			path = g_strconcat (current_dir, "/", uri, NULL);
-			g_free (current_dir);
-		}
-		else 
-			path = g_strdup (uri);
-		
-		window->priv->archive_uri = get_uri_from_local_path (path);
-		 
-		g_free (path);
-	}
-	else
-		window->priv->archive_uri = g_strdup (uri);
+	window->priv->archive_uri = g_strdup (uri);
 
 	window->priv->archive_present = FALSE;
 	window->priv->give_focus_to_the_list = TRUE;
@@ -5494,6 +5476,8 @@
 	window->priv->archive_new = FALSE;
 	window->priv->archive_present = FALSE;
 
+	fr_window_free_open_files (window);
+
 	fr_window_update_title (window);
 	fr_window_update_sensitivity (window);
 	fr_window_update_file_list (window, FALSE);
@@ -7532,8 +7516,6 @@
 	}
 	
 	fr_process_start (window->archive->process);
-	
-	fr_window_free_open_files (window);
 }
 
 
@@ -7635,7 +7617,7 @@
         	return FALSE;
         }
 	
-	first_mime_type = get_file_mime_type (first_file, FALSE);
+	first_mime_type = get_file_mime_type_for_path (first_file, FALSE);
         app = g_app_info_get_default_for_type (first_mime_type, FALSE);
         
         if (app == NULL) {
@@ -7652,7 +7634,7 @@
 			const char *path = scan->data;
 			const char *mime_type;
 
-			mime_type = get_file_mime_type (path, FALSE);
+			mime_type = get_file_mime_type_for_path (path, FALSE);
 			if (mime_type == NULL)
 				continue;
 
@@ -7709,7 +7691,7 @@
 		      gboolean  ask_application)
 {
 	OpenFilesData *odata;
-		
+	
 	odata = open_files_data_new (window, file_list, ask_application);
 	fr_window_set_current_batch_action (window,
 					    FR_BATCH_ACTION_OPEN_FILES,
@@ -7722,14 +7704,14 @@
 			  odata);
 
 	fr_process_clear (window->archive->process);
-	fr_archive_extract (window->archive,
-			    odata->file_list,
-			    odata->cdata->temp_dir,
-			    NULL,
-			    FALSE,
-			    TRUE,
-			    FALSE,
-			    window->priv->password);
+	fr_archive_extract_to_local (window->archive,
+				     odata->file_list,
+				     odata->cdata->temp_dir,
+				     NULL,
+				     FALSE,
+				     TRUE,
+				     FALSE,
+				     window->priv->password);
 	fr_process_start (window->archive->process);
 }
 

Modified: trunk/src/glib-utils.c
==============================================================================
--- trunk/src/glib-utils.c	(original)
+++ trunk/src/glib-utils.c	Sun Apr  6 12:21:25 2008
@@ -559,3 +559,28 @@
 		g_ptr_array_index (array, j) = tmp;
 	}
 }
+
+
+GHashTable *static_strings = NULL;
+
+
+const char *
+get_static_string (const char *s)
+{
+        const char *result;
+
+        if (s == NULL)
+                return NULL;
+
+        if (static_strings == NULL)
+                static_strings = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+        if (! g_hash_table_lookup_extended (static_strings, s, (gpointer*) &result, NULL)) {
+                result = g_strdup (s);
+                g_hash_table_insert (static_strings,
+                                     (gpointer) result,
+                                     GINT_TO_POINTER (1));
+        }
+
+        return result;
+}

Modified: trunk/src/glib-utils.h
==============================================================================
--- trunk/src/glib-utils.h	(original)
+++ trunk/src/glib-utils.h	Sun Apr  6 12:21:25 2008
@@ -47,21 +47,22 @@
 						  const char  *string,
 						  int          flags);
 char **             search_util_get_patterns     (const char  *pattern_string);
-char *              _g_strdup_with_max_size      (const char *s,
-						  int         max_size);
-const char *        eat_spaces                   (const char *line);
-const char *        eat_void_chars               (const char *line);
-char **             split_line                   (const char *line,
-						  int   n_fields);
-const char *        get_last_field               (const char *line,
-						  int         last_field);
-int                 n_fields                     (char      **str_array);
-char *              get_time_string              (time_t      time);
-GPtrArray *         g_ptr_array_copy             (GPtrArray     *array);
-void                g_ptr_array_free_full        (GPtrArray *array,
-                       				  GFunc      func,
-                       				  gpointer   user_data);
-void                g_ptr_array_reverse          (GPtrArray *array);
+char *              _g_strdup_with_max_size      (const char  *s,
+						  int          max_size);
+const char *        eat_spaces                   (const char  *line);
+const char *        eat_void_chars               (const char  *line);
+char **             split_line                   (const char  *line,
+						  int          n_fields);
+const char *        get_last_field               (const char  *line,
+						  int          last_field);
+int                 n_fields                     (char       **str_array);
+char *              get_time_string              (time_t       time);
+GPtrArray *         g_ptr_array_copy             (GPtrArray   *array);
+void                g_ptr_array_free_full        (GPtrArray   *array,
+                       				  GFunc        func,
+                       				  gpointer     user_data);
+void                g_ptr_array_reverse          (GPtrArray   *array);
+const char *        get_static_string            (const char  *s);
 
 /**/
 

Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c	(original)
+++ trunk/src/main.c	Sun Apr  6 12:21:25 2008
@@ -290,7 +290,7 @@
 	if (cdata == NULL)
 		return;
 		
-	if ((cdata->temp_dir != NULL) && uri_is_dir (cdata->temp_dir)) {
+	if ((cdata->temp_dir != NULL) && path_is_dir (cdata->temp_dir)) {
 		char *argv[4];
 
 		argv[0] = "rm";
@@ -305,7 +305,8 @@
 	}
 
 	g_free (cdata->command);
-	g_object_unref (cdata->app);
+	if (cdata->app != NULL)
+		g_object_unref (cdata->app);
 	path_list_free (cdata->file_list);
 	g_free (cdata->temp_dir);
 	if (cdata->process != NULL)
@@ -451,7 +452,7 @@
 	char *full_path;
 	char *uri;
 
-	if (uri_has_scheme (path))
+	if (strstr (path, "://") != NULL)
 		return g_strdup (path);
 
 	if (g_path_is_absolute (path))
@@ -466,7 +467,7 @@
 		g_free (current_dir);
 	}
 
-	uri = get_uri_from_local_path (full_path);
+	uri = g_filename_to_uri (full_path, NULL, NULL);
 	g_free (full_path);
 
 	return uri;

Modified: trunk/src/open-file.c
==============================================================================
--- trunk/src/open-file.c	(original)
+++ trunk/src/open-file.c	Sun Apr  6 12:21:25 2008
@@ -34,7 +34,7 @@
 	
 	ofile = g_new0 (OpenFile, 1);
 	ofile->path = g_strdup (path);
-	ofile->extracted_uri = get_uri_from_local_path (extracted_path);
+	ofile->extracted_uri = g_filename_to_uri (extracted_path, NULL, NULL);
 	ofile->temp_dir = g_strdup (temp_dir);
 	ofile->last_modified = get_file_mtime (ofile->extracted_uri);
 	



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