[file-roller: 73/123] libarchive: implemented fr_archive_update_open_files
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller: 73/123] libarchive: implemented fr_archive_update_open_files
- Date: Mon, 6 Aug 2012 13:47:00 +0000 (UTC)
commit 713b13ca9db06aa0fca35300079f1c08a47a3332
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sun Jul 29 15:57:33 2012 +0200
libarchive: implemented fr_archive_update_open_files
src/fr-archive-libarchive.c | 96 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 96 insertions(+), 0 deletions(-)
---
diff --git a/src/fr-archive-libarchive.c b/src/fr-archive-libarchive.c
index bfb21a7..a7ff183 100644
--- a/src/fr-archive-libarchive.c
+++ b/src/fr-archive-libarchive.c
@@ -418,6 +418,7 @@ extract_archive_thread (GSimpleAsyncResult *result,
/* create the file parents */
parent = g_file_get_parent (file);
+
if ((parent != NULL)
&& (g_hash_table_lookup (checked_folders, parent) == NULL)
&& ! g_file_query_exists (parent, cancellable))
@@ -762,6 +763,8 @@ static void
_archive_write_set_compression_level (struct archive *a,
FrCompression compression)
{
+ /* FIXME: check if the filter supports the option */
+
switch (compression) {
case FR_COMPRESSION_VERY_FAST:
archive_write_set_filter_option (a, NULL, "compression-level", "1");
@@ -1497,6 +1500,57 @@ fr_archive_libarchive_add_dropped_items (FrArchive *archive,
/* -- fr_archive_libarchive_update_open_files -- */
+typedef struct {
+ GList *file_list;
+ GHashTable *files_to_add;
+ int n_files_to_add;
+} UpdateData;
+
+
+static void
+update_data_free (UpdateData *update_data)
+{
+ g_hash_table_unref (update_data->files_to_add);
+ _g_string_list_free (update_data->file_list);
+ g_free (update_data);
+}
+
+
+static void
+_update_open_files_begin (SaveData *save_data,
+ gpointer user_data)
+{
+ UpdateData *update_data = user_data;
+
+ fr_archive_progress_set_total_files (LOAD_DATA (save_data)->archive, update_data->n_files_to_add);
+}
+
+
+static WriteAction
+_update_open_files_entry_action (SaveData *save_data,
+ struct archive_entry *w_entry,
+ gpointer user_data)
+{
+ UpdateData *update_data = user_data;
+ LoadData *load_data = LOAD_DATA (save_data);
+ WriteAction action;
+ const char *pathname;
+ AddFile *add_file;
+
+ action = WRITE_ACTION_WRITE_ENTRY;
+ pathname = archive_entry_pathname (w_entry);
+ add_file = g_hash_table_lookup (update_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);
+ fr_archive_progress_inc_completed_files (load_data->archive, 1);
+ update_data->n_files_to_add--;
+ g_hash_table_remove (update_data->files_to_add, pathname);
+ }
+
+ return action;
+}
+
+
static void
fr_archive_libarchive_update_open_files (FrArchive *archive,
GList *file_list,
@@ -1509,6 +1563,48 @@ fr_archive_libarchive_update_open_files (FrArchive *archive,
GAsyncReadyCallback callback,
gpointer user_data)
{
+ UpdateData *update_data;
+ GList *scan_file;
+ GList *scan_dir;
+
+ update_data = g_new0 (UpdateData, 1);
+ update_data->file_list = _g_string_list_dup (file_list);
+ update_data->files_to_add = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify) add_file_free);
+ update_data->n_files_to_add = 0;
+ for (scan_file = update_data->file_list, scan_dir = dir_list;
+ scan_file && scan_dir;
+ scan_file = scan_file->next, scan_dir = scan_dir->next)
+ {
+ char *temp_dir = scan_dir->data;
+ char *relative_pathname = scan_file->data;
+ char *full_pathname;
+ GFile *file;
+
+ full_pathname = g_build_filename (temp_dir, relative_pathname, NULL);
+ file = g_file_new_for_path (full_pathname);
+ g_hash_table_insert (update_data->files_to_add, relative_pathname, add_file_new (file, relative_pathname));
+ update_data->n_files_to_add++;
+
+ g_object_unref (file);
+ g_free (full_pathname);
+ }
+
+ _fr_archive_libarchive_save (archive,
+ TRUE,
+ password,
+ encrypt_header,
+ compression,
+ volume_size,
+ cancellable,
+ g_simple_async_result_new (G_OBJECT (archive),
+ callback,
+ user_data,
+ fr_archive_update_open_files),
+ _update_open_files_begin,
+ NULL,
+ _update_open_files_entry_action,
+ update_data,
+ (GDestroyNotify) update_data_free);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]