diff options
author | infirit <[email protected]> | 2014-11-21 15:31:24 +0100 |
---|---|---|
committer | infirit <[email protected]> | 2014-11-22 20:25:29 +0100 |
commit | ed78c6d2d8e5ff3b8ae7edd633cce3a266e58d5d (patch) | |
tree | b9924ec79e5b4cc15dcc15800aa6a72fbee0fe97 | |
parent | bfd0f05763c3baa877f696ee5b20f7d5e2f740c2 (diff) | |
download | engrampa-ed78c6d2d8e5ff3b8ae7edd633cce3a266e58d5d.tar.bz2 engrampa-ed78c6d2d8e5ff3b8ae7edd633cce3a266e58d5d.tar.xz |
FrCommand: set the filename before each call to fr_command_* functions
this change will allow the command to use a different filename from
the one pointed to by the local_copy attribute.
Based on FR commit: 5e48592fb49d1f5ce713fcd77d44acd664de4b6a
From: Paolo Bacchilega <[email protected]>
-rw-r--r-- | src/fr-archive.c | 24 | ||||
-rw-r--r-- | src/fr-command-7z.c | 8 | ||||
-rw-r--r-- | src/fr-command-rar.c | 8 | ||||
-rw-r--r-- | src/fr-command.c | 41 | ||||
-rw-r--r-- | src/fr-command.h | 6 | ||||
-rw-r--r-- | src/rar-utils.c | 11 |
6 files changed, 61 insertions, 37 deletions
diff --git a/src/fr-archive.c b/src/fr-archive.c index ad7b84b..598d769 100644 --- a/src/fr-archive.c +++ b/src/fr-archive.c @@ -623,18 +623,13 @@ create_command_from_type (FrArchive *archive, GType command_type, FrCommandCaps requested_capabilities) { - char *filename; - if (command_type == 0) return FALSE; - filename = g_file_get_path (archive->local_copy); archive->command = FR_COMMAND (g_object_new (command_type, "process", archive->process, - "filename", filename, "mime-type", mime_type, NULL)); - g_free (filename); if (! fr_command_is_capable_of (archive->command, requested_capabilities)) { g_object_unref (archive->command); @@ -1202,9 +1197,11 @@ load_local_archive (FrArchive *archive, /**/ fr_process_clear (archive->process); - g_object_set (archive->command, "password", password, NULL); + g_object_set (archive->command, + "file", archive->local_copy, + "password", password, + NULL); fr_command_list (archive->command); - fr_process_start (archive->process); } @@ -1575,6 +1572,7 @@ fr_archive_add (FrArchive *archive, return; g_object_set (archive->command, + "file", archive->local_copy, "password", password, "encrypt_header", encrypt_header, "compression", compression, @@ -2354,6 +2352,7 @@ add_dropped_items (DroppedItemsData *data) fr_archive_stoppable (archive, FALSE); g_object_set (archive->command, + "file", archive->local_copy, "password", data->password, "encrypt_header", data->encrypt_header, "compression", data->compression, @@ -2585,7 +2584,10 @@ fr_archive_remove (FrArchive *archive, return; fr_archive_stoppable (archive, FALSE); - g_object_set (archive->command, "compression", compression, NULL); + g_object_set (archive->command, + "file", archive->local_copy, + "compression", compression, + NULL); fr_command_uncompress (archive->command); delete_from_archive (archive, file_list); fr_command_recompress (archive->command); @@ -2954,6 +2956,7 @@ fr_archive_extract_to_local (FrArchive *archive, g_return_if_fail (archive != NULL); fr_archive_stoppable (archive, TRUE); + g_object_set (archive->command, "file", archive->local_copy, NULL); /* if a command supports all the requested options use * fr_command_extract directly. */ @@ -3307,7 +3310,10 @@ fr_archive_test (FrArchive *archive, { fr_archive_stoppable (archive, TRUE); - g_object_set (archive->command, "password", password, NULL); + g_object_set (archive->command, + "file", archive->local_copy, + "password", password, + NULL); fr_process_clear (archive->process); fr_command_set_n_files (archive->command, 0); fr_command_test (archive->command); diff --git a/src/fr-command-7z.c b/src/fr-command-7z.c index dde039e..29af8cf 100644 --- a/src/fr-command-7z.c +++ b/src/fr-command-7z.c @@ -287,10 +287,14 @@ process_line__add (char *line, FrCommand *comm = FR_COMMAND (data); if ((comm->volume_size > 0) && (strncmp (line, "Creating archive ", 17) == 0)) { - char *volume_filename; + char *volume_filename; + GFile *volume_file; volume_filename = g_strconcat (comm->filename, ".001", NULL); - fr_command_set_multi_volume (comm, volume_filename); + volume_file = g_file_new_for_path (volume_filename); + fr_command_set_multi_volume (comm, volume_file); + + g_object_unref (volume_file); g_free (volume_filename); } diff --git a/src/fr-command-rar.c b/src/fr-command-rar.c index 4daa9fa..bc84229 100644 --- a/src/fr-command-rar.c +++ b/src/fr-command-rar.c @@ -403,11 +403,15 @@ process_line__add (char *line, if ((comm->volume_size > 0) && g_regex_match_simple ("^.*\\.part(0)*2\\.rar$", uri, G_REGEX_CASELESS, 0)) { - char *volume_filename; + char *volume_filename; + GFile *volume_file; volume_filename = g_strdup (archive_filename); volume_filename[strlen (volume_filename) - 5] = '1'; - fr_command_set_multi_volume (comm, volume_filename); + volume_file = g_file_new_for_path (volume_filename); + fr_command_set_multi_volume (comm, volume_file); + + g_object_unref (volume_file); g_free (volume_filename); } fr_command_working_archive (comm, uri); diff --git a/src/fr-command.c b/src/fr-command.c index 31e758a..1f00d84 100644 --- a/src/fr-command.c +++ b/src/fr-command.c @@ -48,7 +48,7 @@ enum { /* Properties */ enum { PROP_0, - PROP_FILENAME, + PROP_FILE, PROP_MIME_TYPE, PROP_PROCESS, PROP_PASSWORD, @@ -289,8 +289,8 @@ fr_command_set_property (GObject *object, case PROP_PROCESS: fr_command_set_process (comm, g_value_get_object (value)); break; - case PROP_FILENAME: - fr_command_set_filename (comm, g_value_get_string (value)); + case PROP_FILE: + fr_command_set_file (comm, g_value_get_object (value)); break; case PROP_MIME_TYPE: fr_command_set_mime_type (comm, g_value_get_string (value)); @@ -328,8 +328,8 @@ fr_command_get_property (GObject *object, case PROP_PROCESS: g_value_set_object (value, comm->process); break; - case PROP_FILENAME: - g_value_set_string (value, comm->filename); + case PROP_FILE: + g_value_take_object (value, g_file_new_for_path (comm->filename)); break; case PROP_MIME_TYPE: g_value_set_static_string (value, comm->mime_type); @@ -444,11 +444,11 @@ fr_command_class_init (FrCommandClass *class) FR_TYPE_PROCESS, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, - PROP_FILENAME, - g_param_spec_string ("filename", - "Filename", - "The archive filename", - NULL, + PROP_FILE, + g_param_spec_object ("file", + "File", + "The archive local file", + G_TYPE_FILE, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, PROP_MIME_TYPE, @@ -542,7 +542,7 @@ fr_command_finalize (GObject *object) } -void +static void fr_command_set_filename (FrCommand *comm, const char *filename) { @@ -583,11 +583,24 @@ fr_command_set_filename (FrCommand *comm, void -fr_command_set_multi_volume (FrCommand *comm, - const char *filename) +fr_command_set_file (FrCommand *comm, + GFile *file) { - comm->multi_volume = TRUE; + char *filename; + + filename = g_file_get_path (file); fr_command_set_filename (comm, filename); + + g_free (filename); +} + + +void +fr_command_set_multi_volume (FrCommand *comm, + GFile *file) +{ + comm->multi_volume = TRUE; + fr_command_set_file (comm, file); } diff --git a/src/fr-command.h b/src/fr-command.h index 7023a8a..c4d87ac 100644 --- a/src/fr-command.h +++ b/src/fr-command.h @@ -169,10 +169,10 @@ struct _FrCommandClass }; GType fr_command_get_type (void); -void fr_command_set_filename (FrCommand *comm, - const char *filename); +void fr_command_set_file (FrCommand *comm, + GFile *file); void fr_command_set_multi_volume (FrCommand *comm, - const char *filename); + GFile *file); void fr_command_list (FrCommand *comm); void fr_command_add (FrCommand *comm, const char *from_file, diff --git a/src/rar-utils.c b/src/rar-utils.c index 0cb34e2..fb67ef9 100644 --- a/src/rar-utils.c +++ b/src/rar-utils.c @@ -119,16 +119,13 @@ rar_check_multi_vomule (FrCommand *comm) if (volume_name != NULL) { GFile *parent; - GFile *child; - char *volume_filename; + GFile *volume_file; parent = g_file_get_parent (file); - child = g_file_get_child (parent, volume_name); - volume_filename = g_file_get_path (child); - fr_command_set_multi_volume (comm, volume_filename); + volume_file = g_file_get_child (parent, volume_name); + fr_command_set_multi_volume (comm, volume_file); - g_free (volume_filename); - g_object_unref (child); + g_object_unref (volume_file); g_object_unref (parent); } |