[file-roller] added option to follow symbolic links



commit d23d89e66a4582254a1230382bb95d1c7167c0bf
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Tue Aug 7 12:46:31 2012 +0200

    added option to follow symbolic links
    
    [new feature]

 data/org.gnome.FileRoller.gschema.xml.in |    2 +-
 src/dlg-add-folder.c                     |   23 +++++++++----
 src/fr-archive-libarchive.c              |   34 ++++++++++++++-----
 src/fr-archive.c                         |   20 +++++++++--
 src/fr-archive.h                         |   10 +++++-
 src/fr-command-7z.c                      |    6 ++-
 src/fr-command-ar.c                      |   13 ++++---
 src/fr-command-arj.c                     |   13 ++++---
 src/fr-command-cfile.c                   |   13 ++++---
 src/fr-command-jar.c                     |   16 +++++-----
 src/fr-command-lha.c                     |   13 ++++---
 src/fr-command-lrzip.c                   |    3 +-
 src/fr-command-rar.c                     |   16 ++++++---
 src/fr-command-rpm.c                     |    1 +
 src/fr-command-tar.c                     |   18 ++++++-----
 src/fr-command-zip.c                     |   17 +++++-----
 src/fr-command-zoo.c                     |   23 +++++++------
 src/fr-command.c                         |   30 +++++++++---------
 src/fr-command.h                         |    2 +-
 src/fr-window.c                          |   51 +++++++++++++++++------------
 src/preferences.h                        |    2 +-
 21 files changed, 198 insertions(+), 128 deletions(-)
---
diff --git a/data/org.gnome.FileRoller.gschema.xml.in b/data/org.gnome.FileRoller.gschema.xml.in
index 049fcaf..9376068 100644
--- a/data/org.gnome.FileRoller.gschema.xml.in
+++ b/data/org.gnome.FileRoller.gschema.xml.in
@@ -190,7 +190,7 @@
       <default>true</default>
     </key>
     <key name="no-symlinks" type="b">
-      <default>false</default>
+      <default>true</default>
     </key>
   </schema>
 
diff --git a/src/dlg-add-folder.c b/src/dlg-add-folder.c
index fdc16b6..0adc335 100644
--- a/src/dlg-add-folder.c
+++ b/src/dlg-add-folder.c
@@ -284,7 +284,7 @@ sync_widgets_with_options (DialogData *data,
 			   const char *exclude_files,
 			   const char *exclude_folders,
 			   gboolean    update,
-			   gboolean    no_symlinks)
+			   gboolean    no_follow_symlinks)
 {
 	if (directory == NULL)
 		directory = fr_window_get_add_default_dir (data->window);
@@ -303,7 +303,16 @@ sync_widgets_with_options (DialogData *data,
 	if (exclude_folders != NULL)
 		gtk_entry_set_text (GTK_ENTRY (GET_WIDGET ("exclude_folders_entry")), exclude_folders);
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("update_checkbutton")), update);
-	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("follow_links_checkbutton")), ! no_symlinks);
+
+	if ((data->window->archive != NULL) && data->window->archive->propAddCanStoreLinks) {
+		gtk_widget_set_sensitive (GET_WIDGET ("follow_links_checkbutton"), TRUE);
+		gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (GET_WIDGET ("follow_links_checkbutton")), FALSE);
+		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("follow_links_checkbutton")), ! no_follow_symlinks);
+	}
+	else {
+		gtk_widget_set_sensitive (GET_WIDGET ("follow_links_checkbutton"), FALSE);
+		gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (GET_WIDGET ("follow_links_checkbutton")), TRUE);
+	}
 }
 
 
@@ -323,7 +332,7 @@ clear_options_activate_cb (GtkMenuItem *menu_item,
 				   "",
 				   "",
 				   FALSE,
-				   FALSE);
+				   TRUE);
 
 	_g_object_unref (folder);
 	_g_object_unref (file);
@@ -409,7 +418,7 @@ dlg_add_folder_load_last_options (DialogData *data)
 	char     *exclude_files = NULL;
 	char     *exclude_folders = NULL;
 	gboolean  update;
-	gboolean  no_symlinks;
+	gboolean  no_follow_symlinks;
 	GFile    *folder;
 	GFile    *file;
 
@@ -421,7 +430,7 @@ dlg_add_folder_load_last_options (DialogData *data)
 	exclude_files = g_settings_get_string (data->settings, PREF_ADD_EXCLUDE_FILES);
 	exclude_folders = g_settings_get_string (data->settings, PREF_ADD_EXCLUDE_FOLDERS);
 	update = g_settings_get_boolean (data->settings, PREF_ADD_UPDATE);
-	no_symlinks = g_settings_get_boolean (data->settings, PREF_ADD_NO_SYMLINKS);
+	no_follow_symlinks = g_settings_get_boolean (data->settings, PREF_ADD_NO_FOLLOW_SYMLINKS);
 
 	sync_widgets_with_options (data,
 				   folder,
@@ -430,7 +439,7 @@ dlg_add_folder_load_last_options (DialogData *data)
 			   	   exclude_files,
 			   	   exclude_folders,
 			   	   update,
-			   	   no_symlinks);
+			   	   no_follow_symlinks);
 
 	_g_object_unref (file);
 	_g_object_unref (folder);
@@ -541,7 +550,7 @@ dlg_add_folder_save_last_options (DialogData *data)
 	g_settings_set_string (data->settings, PREF_ADD_EXCLUDE_FILES, exclude_files);
 	g_settings_set_string (data->settings, PREF_ADD_EXCLUDE_FOLDERS, exclude_folders);
 	g_settings_set_boolean (data->settings, PREF_ADD_UPDATE, update);
-	g_settings_set_boolean (data->settings, PREF_ADD_NO_SYMLINKS, no_symlinks);
+	g_settings_set_boolean (data->settings, PREF_ADD_NO_FOLLOW_SYMLINKS, no_symlinks);
 
 	g_free (base_dir);
 	g_free (filename);
diff --git a/src/fr-archive-libarchive.c b/src/fr-archive-libarchive.c
index 4057465..3dbb9b0 100644
--- a/src/fr-archive-libarchive.c
+++ b/src/fr-archive-libarchive.c
@@ -243,7 +243,11 @@ _g_file_get_size (GFile        *file,
 	GFileInfo *info;
 	goffset    size;
 
-	info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_SIZE, 0, cancellable, NULL);
+	info = g_file_query_info (file,
+				  G_FILE_ATTRIBUTE_STANDARD_SIZE,
+				  G_FILE_QUERY_INFO_NONE,
+				  cancellable,
+				  NULL);
 	if (info == NULL)
 		return 0;
 
@@ -450,7 +454,11 @@ extract_archive_thread (GSimpleAsyncResult *result,
 		if (extract_data->skip_older || ! extract_data->overwrite) {
 			GFileInfo *info;
 
-			info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME "," G_FILE_ATTRIBUTE_TIME_MODIFIED, 0, cancellable, &local_error);
+			info = g_file_query_info (file,
+						  G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME "," G_FILE_ATTRIBUTE_TIME_MODIFIED,
+						  G_FILE_QUERY_INFO_NONE,
+						  cancellable,
+						  &local_error);
 			if (info != NULL) {
 				gboolean skip = FALSE;
 
@@ -969,11 +977,8 @@ _archive_entry_copy_file_info (struct archive_entry *entry,
 	archive_entry_set_nlink (entry, g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_NLINK));
 	archive_entry_set_rdev (entry, g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_RDEV));
 	archive_entry_set_size (entry, g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_STANDARD_SIZE));
-	if (filetype == AE_IFLNK) {
-		/* FIXME: allow to store symlinks */
-		g_print ("symlink: %s\n", g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET));
+	if (filetype == AE_IFLNK)
 		archive_entry_set_symlink (entry, g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET));
-	}
 
 	/* username */
 
@@ -1011,6 +1016,7 @@ static WriteAction
 _archive_write_file (struct archive       *b,
 		     SaveData             *save_data,
 		     AddFile              *add_file,
+		     gboolean              follow_link,
 		     struct archive_entry *r_entry,
 		     GCancellable         *cancellable)
 {
@@ -1023,7 +1029,7 @@ _archive_write_file (struct archive       *b,
 
 	info = g_file_query_info (add_file->file,
 				  FILE_ATTRIBUTES_NEEDED_BY_ARCHIVE_ENTRY,
-				  G_FILE_QUERY_INFO_NONE,
+				  (! follow_link ? G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS : 0),
 				  cancellable,
 				  &load_data->error);
 	if (info == NULL)
@@ -1219,6 +1225,7 @@ _fr_archive_libarchive_save (FrArchive          *archive,
 
 
 typedef struct {
+	gboolean    follow_links;
 	GHashTable *files_to_add;
 	int         n_files_to_add;
 } AddData;
@@ -1232,6 +1239,7 @@ add_data_new (void)
 	add_data = g_new0 (AddData, 1);
 	add_data->files_to_add = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) add_file_free);
 	add_data->n_files_to_add = 0;
+	add_data->follow_links = TRUE;
 
 	return add_data;
 }
@@ -1291,7 +1299,12 @@ _add_files_entry_action (SaveData             *save_data,
 	pathname = archive_entry_pathname (w_entry);
 	add_file = g_hash_table_lookup (add_data->files_to_add, pathname);
 	if (add_file != NULL) {
-		action = _archive_write_file (save_data->b, save_data, add_file, w_entry, load_data->cancellable);
+		action = _archive_write_file (save_data->b,
+					      save_data,
+					      add_file,
+					      add_data->follow_links,
+					      w_entry,
+					      load_data->cancellable);
 		fr_archive_progress_inc_completed_files (load_data->archive, 1);
 		add_data->n_files_to_add--;
 		g_hash_table_remove (add_data->files_to_add, pathname);
@@ -1327,6 +1340,7 @@ _add_files_end (SaveData *save_data,
 		if (_archive_write_file (save_data->b,
 					 save_data,
 					 add_file,
+					 add_data->follow_links,
 					 NULL,
 					 load_data->cancellable) == WRITE_ACTION_ABORT)
 		{
@@ -1346,7 +1360,7 @@ fr_archive_libarchive_add_files (FrArchive           *archive,
 				 GFile               *base_dir,
 				 const char          *dest_dir,
 				 gboolean             update,
-				 gboolean             recursive,
+				 gboolean             follow_links,
 				 const char          *password,
 				 gboolean             encrypt_header,
 				 FrCompression        compression,
@@ -1361,6 +1375,7 @@ fr_archive_libarchive_add_files (FrArchive           *archive,
 	g_return_if_fail (base_dir != NULL);
 
 	add_data = add_data_new ();
+	add_data->follow_links = follow_links;
 
 	if (dest_dir != NULL)
 		dest_dir = (dest_dir[0] == '/' ? dest_dir + 1 : dest_dir);
@@ -1827,6 +1842,7 @@ fr_archive_libarchive_init (FrArchiveLibarchive *self)
 	base->propAddCanReplace = TRUE;
 	base->propAddCanUpdate = TRUE;
 	base->propAddCanStoreFolders = TRUE;
+	base->propAddCanStoreLinks = TRUE;
 	base->propExtractCanAvoidOverwrite = TRUE;
 	base->propExtractCanSkipOlder = TRUE;
 	base->propExtractCanJunkPaths = TRUE;
diff --git a/src/fr-archive.c b/src/fr-archive.c
index 154efb9..fb2fe27 100644
--- a/src/fr-archive.c
+++ b/src/fr-archive.c
@@ -446,6 +446,7 @@ fr_archive_init (FrArchive *self)
         self->propAddCanUpdate = FALSE;
         self->propAddCanReplace = FALSE;
         self->propAddCanStoreFolders = FALSE;
+        self->propAddCanStoreLinks = FALSE;
         self->propExtractCanAvoidOverwrite = FALSE;
         self->propExtractCanSkipOlder = FALSE;
         self->propExtractCanJunkPaths = FALSE;
@@ -1001,6 +1002,7 @@ typedef struct {
 	GFile               *base_dir;
 	char                *dest_dir;
 	gboolean             update;
+	gboolean             follow_links;
 	char                *password;
 	gboolean             encrypt_header;
 	FrCompression        compression;
@@ -1082,7 +1084,7 @@ fr_archive_add_files_ready_cb (GList    *file_info_list, /* FileInfo list */
 								   add_data->base_dir,
 								   add_data->dest_dir,
 								   add_data->update,
-								   FALSE,
+								   add_data->follow_links,
 								   add_data->password,
 								   add_data->encrypt_header,
 								   add_data->compression,
@@ -1106,6 +1108,7 @@ fr_archive_add_files (FrArchive           *archive,
 		      GFile               *base_dir,
 		      const char          *dest_dir,
 		      gboolean             update,
+		      gboolean             follow_links,
 		      const char          *password,
 		      gboolean             encrypt_header,
 		      FrCompression        compression,
@@ -1124,6 +1127,7 @@ fr_archive_add_files (FrArchive           *archive,
 	add_data->base_dir = _g_object_ref (base_dir);
 	add_data->dest_dir = g_strdup (dest_dir);
 	add_data->update = update;
+	add_data->follow_links = follow_links;
 	add_data->password = g_strdup (password);
 	add_data->encrypt_header = encrypt_header;
 	add_data->compression = compression;
@@ -1195,8 +1199,9 @@ fr_archive_add_files_with_filter (FrArchive           *archive,
 				  GAsyncReadyCallback  callback,
 				  gpointer             user_data)
 {
-	AddData *add_data;
-	GList   *file_list;
+	AddData       *add_data;
+	GList         *file_list;
+	FileListFlags  flags;
 
 	g_return_if_fail (! archive->read_only);
 
@@ -1205,6 +1210,7 @@ fr_archive_add_files_with_filter (FrArchive           *archive,
 	add_data->base_dir = _g_object_ref (source_dir);
 	add_data->dest_dir = g_strdup (dest_dir);
 	add_data->update = update;
+	add_data->follow_links = follow_links;
 	add_data->password = g_strdup (password);
 	add_data->encrypt_header = encrypt_header;
 	add_data->compression = compression;
@@ -1219,8 +1225,11 @@ fr_archive_add_files_with_filter (FrArchive           *archive,
 	fr_archive_action_started (archive, FR_ACTION_GETTING_FILE_LIST);
 
 	file_list = g_list_prepend (NULL, source_dir);
+	flags = FILE_LIST_RECURSIVE | FILE_LIST_NO_BACKUP_FILES;
+	if (! follow_links)
+		flags |= FILE_LIST_NO_FOLLOW_LINKS;
 	_g_file_list_query_info_async (file_list,
-				       FILE_LIST_RECURSIVE | FILE_LIST_NO_BACKUP_FILES,
+				       flags,
 				       (G_FILE_ATTRIBUTE_STANDARD_NAME ","
 					G_FILE_ATTRIBUTE_STANDARD_SIZE ","
 					G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN ","
@@ -1707,6 +1716,7 @@ add_dropped_items (DroppedItemsData *data)
 				      first_parent,
 				      data->dest_dir,
 				      FALSE,
+				      FALSE,
 				      data->password,
 				      data->encrypt_header,
 				      data->compression,
@@ -1739,6 +1749,7 @@ add_dropped_items (DroppedItemsData *data)
 				      parent,
 				      data->dest_dir,
 				      FALSE,
+				      FALSE,
 				      data->password,
 				      data->encrypt_header,
 				      data->compression,
@@ -1769,6 +1780,7 @@ add_dropped_items (DroppedItemsData *data)
 				      first_parent,
 				      data->dest_dir,
 				      FALSE,
+				      FALSE,
 				      data->password,
 				      data->encrypt_header,
 				      data->compression,
diff --git a/src/fr-archive.h b/src/fr-archive.h
index a4b78cc..b24d68e 100644
--- a/src/fr-archive.h
+++ b/src/fr-archive.h
@@ -114,6 +114,13 @@ struct _FrArchive {
 	 */
 	guint          propAddCanStoreFolders : 1;
 
+	/*
+	 * propAddCanStoreLinks
+	 *
+	 * TRUE if the command can store symbolic links
+	 */
+	guint          propAddCanStoreLinks : 1;
+
 	/* propExtractCanAvoidOverwrite:
 	 *
 	 * TRUE if the command can avoid to overwrite the files on disk.
@@ -229,7 +236,7 @@ struct _FrArchiveClass {
 					    GFile               *base_dir,
 					    const char          *dest_dir,
 					    gboolean             update,
-					    gboolean             recursive,
+					    gboolean             follow_links,
 					    const char          *password,
 					    gboolean             encrypt_header,
 					    FrCompression        compression,
@@ -344,6 +351,7 @@ void          fr_archive_add_files               (FrArchive           *archive,
 						  GFile               *base_dir,
 						  const char          *dest_dir,
 						  gboolean             update,
+						  gboolean             follow_links,
 						  const char          *password,
 						  gboolean             encrypt_header,
 						  FrCompression        compression,
diff --git a/src/fr-command-7z.c b/src/fr-command-7z.c
index ab59fa9..3d18370 100644
--- a/src/fr-command-7z.c
+++ b/src/fr-command-7z.c
@@ -304,7 +304,7 @@ fr_command_7z_add (FrCommand  *command,
 		   GList      *file_list,
 		   const char *base_dir,
 		   gboolean    update,
-		   gboolean    recursive)
+		   gboolean    follow_links)
 {
 	FrArchive *archive = FR_ARCHIVE (command);
 	GList     *scan;
@@ -335,7 +335,8 @@ fr_command_7z_add (FrCommand  *command,
 
 	fr_process_add_arg (command->process, "-bd");
 	fr_process_add_arg (command->process, "-y");
-	fr_process_add_arg (command->process, "-l");
+	if (follow_links)
+		fr_process_add_arg (command->process, "-l");
 	add_password_arg (command, archive->password, FALSE);
 	if ((archive->password != NULL)
 	    && (*archive->password != 0)
@@ -668,6 +669,7 @@ fr_command_7z_init (FrCommand7z *self)
 	base->propAddCanUpdate             = TRUE;
 	base->propAddCanReplace            = TRUE;
 	base->propAddCanStoreFolders       = TRUE;
+	base->propAddCanStoreLinks         = TRUE;
 	base->propExtractCanAvoidOverwrite = FALSE;
 	base->propExtractCanSkipOlder      = FALSE;
 	base->propExtractCanJunkPaths      = TRUE;
diff --git a/src/fr-command-ar.c b/src/fr-command-ar.c
index 84c49e5..eda3196 100644
--- a/src/fr-command-ar.c
+++ b/src/fr-command-ar.c
@@ -195,12 +195,12 @@ fr_command_ar_list (FrCommand *comm)
 
 
 static void
-fr_command_ar_add (FrCommand     *comm,
-		   const char    *from_file,
-		   GList         *file_list,
-		   const char    *base_dir,
-		   gboolean       update,
-		   gboolean       recursive)
+fr_command_ar_add (FrCommand  *comm,
+		   const char *from_file,
+		   GList      *file_list,
+		   const char *base_dir,
+		   gboolean    update,
+		   gboolean    follow_links)
 {
 	GList *scan;
 
@@ -355,6 +355,7 @@ fr_command_ar_init (FrCommandAr *self)
 	base->propAddCanUpdate             = TRUE;
 	base->propAddCanReplace            = TRUE;
 	base->propAddCanStoreFolders       = FALSE;
+	base->propAddCanStoreLinks         = FALSE;
 	base->propExtractCanAvoidOverwrite = FALSE;
 	base->propExtractCanSkipOlder      = FALSE;
 	base->propExtractCanJunkPaths      = FALSE;
diff --git a/src/fr-command-arj.c b/src/fr-command-arj.c
index c603fdf..808ff88 100644
--- a/src/fr-command-arj.c
+++ b/src/fr-command-arj.c
@@ -168,12 +168,12 @@ fr_command_arj_list (FrCommand *comm)
 
 
 static void
-fr_command_arj_add (FrCommand     *comm,
-		    const char    *from_file,
-		    GList         *file_list,
-		    const char    *base_dir,
-		    gboolean       update,
-		    gboolean       recursive)
+fr_command_arj_add (FrCommand  *comm,
+		    const char *from_file,
+		    GList      *file_list,
+		    const char *base_dir,
+		    gboolean    update,
+		    gboolean    follow_links)
 {
 	GList *scan;
 
@@ -393,6 +393,7 @@ fr_command_arj_init (FrCommandArj *self)
 	base->propAddCanUpdate             = TRUE;
 	base->propAddCanReplace            = TRUE;
 	base->propAddCanStoreFolders       = FALSE;
+	base->propAddCanStoreLinks         = FALSE;
 	base->propExtractCanAvoidOverwrite = TRUE;
 	base->propExtractCanSkipOlder      = TRUE;
 	base->propExtractCanJunkPaths      = TRUE;
diff --git a/src/fr-command-cfile.c b/src/fr-command-cfile.c
index 5dcce81..ce2df59 100644
--- a/src/fr-command-cfile.c
+++ b/src/fr-command-cfile.c
@@ -190,12 +190,12 @@ fr_command_cfile_list (FrCommand *comm)
 
 
 static void
-fr_command_cfile_add (FrCommand     *comm,
-		      const char    *from_file,
-		      GList         *file_list,
-		      const char    *base_dir,
-		      gboolean       update,
-		      gboolean       recursive)
+fr_command_cfile_add (FrCommand  *comm,
+		      const char *from_file,
+		      GList      *file_list,
+		      const char *base_dir,
+		      gboolean    update,
+		      gboolean    follow_links)
 {
 	FrArchive  *archive = FR_ARCHIVE (comm);
 	const char *filename;
@@ -587,6 +587,7 @@ fr_command_cfile_init (FrCommandCFile *self)
 
 	base->propAddCanUpdate             = TRUE;
 	base->propAddCanReplace            = TRUE;
+	base->propAddCanStoreLinks         = FALSE;
 	base->propExtractCanAvoidOverwrite = FALSE;
 	base->propExtractCanSkipOlder      = FALSE;
 	base->propExtractCanJunkPaths      = FALSE;
diff --git a/src/fr-command-jar.c b/src/fr-command-jar.c
index 4b999ab..d7eeffd 100644
--- a/src/fr-command-jar.c
+++ b/src/fr-command-jar.c
@@ -43,12 +43,12 @@ typedef struct {
 
 
 static void
-fr_command_jar_add (FrCommand     *comm,
-		    const char    *from_file,
-		    GList         *file_list,
-		    const char    *base_dir,
-		    gboolean       update,
-		    gboolean       recursive)
+fr_command_jar_add (FrCommand  *comm,
+		    const char *from_file,
+		    GList      *file_list,
+		    const char *base_dir,
+		    gboolean    update,
+		    gboolean    follow_links)
 {
 	FrProcess *proc = comm->process;
 	GList     *zip_list = NULL, *jardata_list = NULL, *jar_list = NULL;
@@ -116,10 +116,10 @@ fr_command_jar_add (FrCommand     *comm,
 	}
 
 	if (zip_list != NULL)
-		FR_COMMAND_CLASS (fr_command_jar_parent_class)->add (comm, NULL, zip_list, base_dir, update, FALSE);
+		FR_COMMAND_CLASS (fr_command_jar_parent_class)->add (comm, NULL, zip_list, base_dir, update, follow_links);
 
 	if (jar_list != NULL)
-		FR_COMMAND_CLASS (fr_command_jar_parent_class)->add (comm, NULL, jar_list, tmp_dir, update, FALSE);
+		FR_COMMAND_CLASS (fr_command_jar_parent_class)->add (comm, NULL, jar_list, tmp_dir, update, follow_links);
 
 	fr_process_begin_command (proc, "rm");
 	fr_process_set_working_dir (proc, "/");
diff --git a/src/fr-command-lha.c b/src/fr-command-lha.c
index da5c577..c4f6c91 100644
--- a/src/fr-command-lha.c
+++ b/src/fr-command-lha.c
@@ -216,12 +216,12 @@ fr_command_lha_list (FrCommand  *comm)
 
 
 static void
-fr_command_lha_add (FrCommand     *comm,
-		    const char    *from_file,
-		    GList         *file_list,
-		    const char    *base_dir,
-		    gboolean       update,
-		    gboolean       recursive)
+fr_command_lha_add (FrCommand  *comm,
+		    const char *from_file,
+		    GList      *file_list,
+		    const char *base_dir,
+		    gboolean    update,
+		    gboolean    follow_links)
 {
 	GList *scan;
 
@@ -371,6 +371,7 @@ fr_command_lha_init (FrCommandLha *self)
 	base->propAddCanUpdate             = TRUE;
 	base->propAddCanReplace            = TRUE;
 	base->propAddCanStoreFolders       = TRUE;
+	base->propAddCanStoreLinks         = FALSE;
 	base->propExtractCanAvoidOverwrite = FALSE;
 	base->propExtractCanSkipOlder      = FALSE;
 	base->propExtractCanJunkPaths      = TRUE;
diff --git a/src/fr-command-lrzip.c b/src/fr-command-lrzip.c
index de73fd9..ad53a13 100644
--- a/src/fr-command-lrzip.c
+++ b/src/fr-command-lrzip.c
@@ -95,7 +95,7 @@ fr_command_lrzip_add (FrCommand  *comm,
 		      GList      *file_list,
 		      const char *base_dir,
 		      gboolean    update,
-		      gboolean    recursive)
+		      gboolean    follow_links)
 {
 	fr_process_begin_command (comm->process, "lrzip");
 
@@ -233,6 +233,7 @@ fr_command_lrzip_init (FrCommandLrzip *self)
 	base->propAddCanUpdate             = FALSE;
 	base->propAddCanReplace            = FALSE;
 	base->propAddCanStoreFolders       = FALSE;
+	base->propAddCanStoreLinks         = FALSE;
 	base->propExtractCanAvoidOverwrite = TRUE;
 	base->propExtractCanSkipOlder      = FALSE;
 	base->propExtractCanJunkPaths      = FALSE;
diff --git a/src/fr-command-rar.c b/src/fr-command-rar.c
index 7a4fe0d..ba58304 100644
--- a/src/fr-command-rar.c
+++ b/src/fr-command-rar.c
@@ -327,12 +327,12 @@ process_line__add (char     *line,
 
 
 static void
-fr_command_rar_add (FrCommand     *comm,
-		    const char    *from_file,
-		    GList         *file_list,
-		    const char    *base_dir,
-		    gboolean       update,
-		    gboolean       recursive)
+fr_command_rar_add (FrCommand  *comm,
+		    const char *from_file,
+		    GList      *file_list,
+		    const char *base_dir,
+		    gboolean    update,
+		    gboolean    follow_links)
 {
 	GList *scan;
 
@@ -351,6 +351,9 @@ fr_command_rar_add (FrCommand     *comm,
 	else
 		fr_process_add_arg (comm->process, "a");
 
+	if (! follow_links)
+		fr_process_add_arg (comm->process, "-ol");
+
 	switch (FR_ARCHIVE (comm)->compression) {
 	case FR_COMPRESSION_VERY_FAST:
 		fr_process_add_arg (comm->process, "-m1"); break;
@@ -671,6 +674,7 @@ fr_command_rar_init (FrCommandRar *self)
 	base->propAddCanUpdate             = TRUE;
 	base->propAddCanReplace            = TRUE;
 	base->propAddCanStoreFolders       = TRUE;
+	base->propAddCanStoreLinks         = TRUE;
 	base->propExtractCanAvoidOverwrite = TRUE;
 	base->propExtractCanSkipOlder      = TRUE;
 	base->propExtractCanJunkPaths      = TRUE;
diff --git a/src/fr-command-rpm.c b/src/fr-command-rpm.c
index 5593799..035ac5e 100644
--- a/src/fr-command-rpm.c
+++ b/src/fr-command-rpm.c
@@ -291,6 +291,7 @@ fr_command_rpm_init (FrCommandRpm *self)
 
 	base->propAddCanUpdate             = FALSE;
 	base->propAddCanReplace            = FALSE;
+	base->propAddCanStoreLinks         = FALSE;
 	base->propExtractCanAvoidOverwrite = FALSE;
 	base->propExtractCanSkipOlder      = FALSE;
 	base->propExtractCanJunkPaths      = FALSE;
diff --git a/src/fr-command-tar.c b/src/fr-command-tar.c
index f630fb6..3ca7be9 100644
--- a/src/fr-command-tar.c
+++ b/src/fr-command-tar.c
@@ -307,12 +307,12 @@ process_line__add (char     *line,
 
 
 static void
-fr_command_tar_add (FrCommand     *comm,
-		    const char    *from_file,
-		    GList         *file_list,
-		    const char    *base_dir,
-		    gboolean       update,
-		    gboolean       recursive)
+fr_command_tar_add (FrCommand  *comm,
+		    const char *from_file,
+		    GList      *file_list,
+		    const char *base_dir,
+		    gboolean    update,
+		    gboolean    follow_links)
 {
 	FrCommandTar *c_tar = FR_COMMAND_TAR (comm);
 	GList        *scan;
@@ -323,11 +323,12 @@ fr_command_tar_add (FrCommand     *comm,
 
 	begin_tar_command (comm);
 	fr_process_add_arg (comm->process, "--force-local");
-	if (! recursive)
-		fr_process_add_arg (comm->process, "--no-recursion");
+	fr_process_add_arg (comm->process, "--no-recursion");
 	fr_process_add_arg (comm->process, "--no-wildcards");
 	fr_process_add_arg (comm->process, "-v");
 	fr_process_add_arg (comm->process, "-p");
+	if (follow_links)
+		fr_process_add_arg (comm->process, "-h");
 
 	if (base_dir != NULL) {
 		fr_process_add_arg (comm->process, "-C");
@@ -1180,6 +1181,7 @@ fr_command_tar_init (FrCommandTar *self)
 	base->propAddCanUpdate              = FALSE;
 	base->propAddCanReplace             = FALSE;
 	base->propAddCanStoreFolders        = TRUE;
+	base->propAddCanStoreLinks          = TRUE;
 	base->propExtractCanAvoidOverwrite  = FALSE;
 	base->propExtractCanSkipOlder       = TRUE;
 	base->propExtractCanJunkPaths       = FALSE;
diff --git a/src/fr-command-zip.c b/src/fr-command-zip.c
index 617818d..32baf78 100644
--- a/src/fr-command-zip.c
+++ b/src/fr-command-zip.c
@@ -208,12 +208,12 @@ process_line__common (char     *line,
 
 
 static void
-fr_command_zip_add (FrCommand     *comm,
-		    const char    *from_file,
-		    GList         *file_list,
-		    const char    *base_dir,
-		    gboolean       update,
-		    gboolean       recursive)
+fr_command_zip_add (FrCommand  *comm,
+		    const char *from_file,
+		    GList      *file_list,
+		    const char *base_dir,
+		    gboolean    update,
+		    gboolean    follow_links)
 {
 	GList *scan;
 
@@ -226,8 +226,8 @@ fr_command_zip_add (FrCommand     *comm,
 	if (base_dir != NULL)
 		fr_process_set_working_dir (comm->process, base_dir);
 
-	/* preserve links. */
-	fr_process_add_arg (comm->process, "-y");
+	if (! follow_links)
+		fr_process_add_arg (comm->process, "-y");
 
 	if (update)
 		fr_process_add_arg (comm->process, "-u");
@@ -463,6 +463,7 @@ fr_command_zip_init (FrCommandZip *self)
 	base->propAddCanUpdate             = TRUE;
 	base->propAddCanReplace            = TRUE;
 	base->propAddCanStoreFolders       = TRUE;
+	base->propAddCanStoreLinks         = TRUE;
 	base->propExtractCanAvoidOverwrite = TRUE;
 	base->propExtractCanSkipOlder      = TRUE;
 	base->propExtractCanJunkPaths      = TRUE;
diff --git a/src/fr-command-zoo.c b/src/fr-command-zoo.c
index a5b6826..f372f99 100644
--- a/src/fr-command-zoo.c
+++ b/src/fr-command-zoo.c
@@ -226,14 +226,14 @@ fr_command_zoo_list (FrCommand  *zoo_comm)
 
 
 static void
-fr_command_zoo_add (FrCommand     *comm,
-		    const char    *from_file,
-		    GList         *file_list,
-		    const char    *base_dir,
-		    gboolean       update,
-		    gboolean       recursive)
+fr_command_zoo_add (FrCommand  *comm,
+		    const char *from_file,
+		    GList      *file_list,
+		    const char *base_dir,
+		    gboolean    update,
+		    gboolean    follow_links)
 {
-	GList        *scan;
+	GList *scan;
 
 	/* Add files. */
 
@@ -255,11 +255,11 @@ fr_command_zoo_add (FrCommand     *comm,
 
 
 static void
-fr_command_zoo_delete (FrCommand *comm,
-		       const char  *from_file,
-		       GList     *file_list)
+fr_command_zoo_delete (FrCommand  *comm,
+		       const char *from_file,
+		       GList      *file_list)
 {
-	GList        *scan;
+	GList *scan;
 
 	/* Delete files. */
 
@@ -390,6 +390,7 @@ fr_command_zoo_init (FrCommandZoo *self)
 
 	base->propAddCanUpdate             = TRUE;
 	base->propAddCanReplace            = FALSE;
+	base->propAddCanStoreLinks         = FALSE;
 	base->propExtractCanAvoidOverwrite = FALSE;
 	base->propExtractCanSkipOlder      = FALSE;
 	base->propExtractCanJunkPaths      = FALSE;
diff --git a/src/fr-command.c b/src/fr-command.c
index 570ab2d..304d520 100644
--- a/src/fr-command.c
+++ b/src/fr-command.c
@@ -56,7 +56,7 @@ typedef struct {
 	GFile              *base_dir;
 	char               *dest_dir;
 	gboolean            update;
-	gboolean            recursive;
+	gboolean            follow_links;
 	GFile              *tmp_dir;
 	guint               source_id;
 	char               *password;
@@ -327,7 +327,7 @@ fr_command_add (FrCommand  *self,
 		GList      *file_list,
 		GFile      *base_dir,
 		gboolean    update,
-		gboolean    recursive)
+		gboolean    follow_links)
 {
 	char *base_dir_path;
 
@@ -341,7 +341,7 @@ fr_command_add (FrCommand  *self,
 						     file_list,
 						     base_dir_path,
 						     update,
-						     recursive);
+						     follow_links);
 
 	g_free (base_dir_path);
 }
@@ -964,7 +964,7 @@ _fr_command_add (FrCommand      *self,
 		 GFile          *base_dir,
 		 const char     *dest_dir,
 		 gboolean        update,
-		 gboolean        recursive,
+		 gboolean        follow_links,
 		 const char     *password,
 		 gboolean        encrypt_header,
 		 FrCompression   compression,
@@ -1125,7 +1125,7 @@ _fr_command_add (FrCommand      *self,
 					new_file_list,
 					tmp_base_dir,
 					update,
-					recursive);
+					follow_links);
 
 			/* remove the temp dir */
 
@@ -1156,7 +1156,7 @@ _fr_command_add (FrCommand      *self,
 					chunk,
 					tmp_base_dir,
 					update,
-					recursive);
+					follow_links);
 			g_list_free (chunk);
 		}
 
@@ -1276,7 +1276,7 @@ _fr_command_add_local_files (FrCommand           *self,
 			     GFile               *base_dir,
 			     const char          *dest_dir,
 			     gboolean             update,
-			     gboolean             recursive,
+			     gboolean             follow_links,
 			     const char          *password,
 			     gboolean             encrypt_header,
 			     FrCompression        compression,
@@ -1297,7 +1297,7 @@ _fr_command_add_local_files (FrCommand           *self,
 			       base_dir,
 			       dest_dir,
 			       update,
-			       recursive,
+			       follow_links,
 			       password,
 			       encrypt_header,
 			       compression,
@@ -1344,8 +1344,8 @@ copy_remote_files_done (GError   *error,
 					     xfer_data->file_list,
 					     xfer_data->tmp_dir,
 					     xfer_data->dest_dir,
-					     FALSE,
-					     xfer_data->recursive,
+					     xfer_data->update,
+					     xfer_data->follow_links,
 					     xfer_data->password,
 					     xfer_data->encrypt_header,
 					     xfer_data->compression,
@@ -1378,7 +1378,7 @@ copy_remote_files (FrCommand           *self,
 		   GFile               *base_dir,
 		   const char          *dest_dir,
 		   gboolean             update,
-		   gboolean             recursive,
+		   gboolean             follow_links,
 		   const char          *password,
 		   gboolean             encrypt_header,
 		   FrCompression        compression,
@@ -1442,7 +1442,7 @@ copy_remote_files (FrCommand           *self,
 	xfer_data->base_dir = g_object_ref (base_dir);
 	xfer_data->dest_dir = g_strdup (dest_dir);
 	xfer_data->update = update;
-	xfer_data->recursive = recursive;
+	xfer_data->follow_links = follow_links;
 	xfer_data->dest_dir = g_strdup (dest_dir);
 	xfer_data->password = g_strdup (password);
 	xfer_data->encrypt_header = encrypt_header;
@@ -1475,7 +1475,7 @@ fr_command_add_files (FrArchive           *base,
 		      GFile               *base_dir,
 		      const char          *dest_dir,
 		      gboolean             update,
-		      gboolean             recursive,
+		      gboolean             follow_links,
 		      const char          *password,
 		      gboolean             encrypt_header,
 		      FrCompression        compression,
@@ -1498,7 +1498,7 @@ fr_command_add_files (FrArchive           *base,
 					     base_dir,
 					     dest_dir,
 					     update,
-					     recursive,
+					     follow_links,
 					     password,
 					     encrypt_header,
 					     compression,
@@ -1511,7 +1511,7 @@ fr_command_add_files (FrArchive           *base,
 				   base_dir,
 				   dest_dir,
 				   update,
-				   recursive,
+				   follow_links,
 				   password,
 				   encrypt_header,
 				   compression,
diff --git a/src/fr-command.h b/src/fr-command.h
index 9ba01e9..1acf220 100644
--- a/src/fr-command.h
+++ b/src/fr-command.h
@@ -63,7 +63,7 @@ struct _FrCommandClass {
 				     GList       *file_list,
 				     const char  *base_dir,
 				     gboolean     update,
-				     gboolean     recursive);
+				     gboolean     follow_links);
 	void      (*delete)         (FrCommand   *comm,
 		                     const char  *from_file,
 		                     GList       *file_list);
diff --git a/src/fr-window.c b/src/fr-window.c
index 098192c..c8daf14 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -1605,6 +1605,21 @@ get_icon (GtkWidget *widget,
 	const char *content_type;
 	GIcon      *icon;
 
+	if (fdata->link != NULL) {
+		pixbuf = g_hash_table_lookup (pixbuf_hash, "emblem-symbolic-link");
+		if (pixbuf != NULL)
+			return g_object_ref (G_OBJECT (pixbuf));
+
+		pixbuf = gtk_icon_theme_load_icon (icon_theme,
+						   "emblem-symbolic-link",
+						   file_list_icon_size,
+						   0,
+						   NULL);
+		g_hash_table_insert (pixbuf_hash, (gpointer) "emblem-symbolic-link", pixbuf);
+
+		return g_object_ref (G_OBJECT (pixbuf));
+	}
+
 	if (file_data_is_dir (fdata))
 		content_type = MIME_TYPE_DIRECTORY;
 	else
@@ -1613,10 +1628,8 @@ get_icon (GtkWidget *widget,
 	/* look in the hash table. */
 
 	pixbuf = g_hash_table_lookup (pixbuf_hash, content_type);
-	if (pixbuf != NULL) {
-		g_object_ref (G_OBJECT (pixbuf));
-		return pixbuf;
-	}
+	if (pixbuf != NULL)
+		return g_object_ref (G_OBJECT (pixbuf));
 
 	icon = g_content_type_get_icon (content_type);
 	pixbuf = _g_icon_get_pixbuf (icon, file_list_icon_size, icon_theme);
@@ -1625,11 +1638,9 @@ get_icon (GtkWidget *widget,
 	if (pixbuf == NULL)
 		return NULL;
 
-	pixbuf = gdk_pixbuf_copy (pixbuf);
 	g_hash_table_insert (pixbuf_hash, (gpointer) content_type, pixbuf);
-	g_object_ref (G_OBJECT (pixbuf));
 
-	return pixbuf;
+	return g_object_ref (G_OBJECT (pixbuf));
 }
 
 
@@ -1637,32 +1648,29 @@ static GdkPixbuf *
 get_emblem (GtkWidget *widget,
 	    FileData  *fdata)
 {
-	GdkPixbuf *pixbuf = NULL;
+	const char *emblem_name = NULL;
+	GdkPixbuf  *pixbuf;
 
-	if (! fdata->encrypted)
-		return NULL;
+	if (fdata->encrypted)
+		emblem_name = "emblem-nowrite";
 
-	/* encrypted */
+	if (emblem_name == NULL)
+		return NULL;
 
-	pixbuf = g_hash_table_lookup (pixbuf_hash, "emblem-nowrite");
+	pixbuf = g_hash_table_lookup (pixbuf_hash, emblem_name);
 	if (pixbuf != NULL) {
 		g_object_ref (G_OBJECT (pixbuf));
 		return pixbuf;
 	}
 
 	pixbuf = gtk_icon_theme_load_icon (icon_theme,
-					   "emblem-nowrite",
+					   emblem_name,
 					   file_list_icon_size,
 					   0,
 					   NULL);
-	if (pixbuf == NULL)
-		return NULL;
+	g_hash_table_insert (pixbuf_hash, (gpointer) emblem_name, pixbuf);
 
-	pixbuf = gdk_pixbuf_copy (pixbuf);
-	g_hash_table_insert (pixbuf_hash, (gpointer) "emblem-nowrite", pixbuf);
-	g_object_ref (G_OBJECT (pixbuf));
-
-	return pixbuf;
+	return g_object_ref (G_OBJECT (pixbuf));
 }
 
 
@@ -6486,6 +6494,7 @@ fr_window_archive_add_files (FrWindow   *window,
 			      base_dir,
 			      fr_window_get_current_location (window),
 			      update,
+			      FALSE,
 			      window->priv->password,
 			      window->priv->encrypt_header,
 			      window->priv->compression,
@@ -7503,7 +7512,7 @@ archive_extraction_ready_for_convertion_cb (GObject      *source_object,
 					  NULL,
 					  NULL,
 					  FALSE,
-					  TRUE,
+					  FALSE,
 					  window->priv->convert_data.password,
 					  window->priv->convert_data.encrypt_header,
 					  window->priv->compression,
diff --git a/src/preferences.h b/src/preferences.h
index 1ae3195..02e9b5d 100644
--- a/src/preferences.h
+++ b/src/preferences.h
@@ -68,7 +68,7 @@
 #define PREF_ADD_EXCLUDE_FOLDERS          "exclude-folders"
 #define PREF_ADD_UPDATE                   "update"
 #define PREF_ADD_RECURSIVE                "recursive"
-#define PREF_ADD_NO_SYMLINKS              "no-symlinks"
+#define PREF_ADD_NO_FOLLOW_SYMLINKS       "no-symlinks"
 
 #define PREF_BATCH_ADD_DEFAULT_EXTENSION  "default-extension"
 #define PREF_BATCH_ADD_OTHER_OPTIONS      "other-options"



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