[gnome-autoar/wip/razvan/general-improvements: 15/20] AutoarExtract: rename to AutoarExtractor
- From: Răzvan-Mihai Chițu <razvanchitu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-autoar/wip/razvan/general-improvements: 15/20] AutoarExtract: rename to AutoarExtractor
- Date: Fri, 19 Aug 2016 17:31:00 +0000 (UTC)
commit cb228589f312a180569162aba11ed870ec5ca776
Author: Razvan Chitu <razvan ch95 gmail com>
Date: Tue Aug 16 21:15:59 2016 +0300
AutoarExtract: rename to AutoarExtractor
https://bugzilla.gnome.org/show_bug.cgi?id=768645
Makefile.am | 4 +-
gnome-autoar/autoar-extract.h | 86 --
.../{autoar-extract.c => autoar-extractor.c} | 1081 ++++++++++----------
gnome-autoar/autoar-extractor.h | 86 ++
gnome-autoar/autoar.h | 2 +-
tests/test-extract-unit.c | 102 +-
tests/test-extract.c | 36 +-
7 files changed, 710 insertions(+), 687 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 449b67c..cab2d70 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,14 +23,14 @@ EXTRA_DIST += \
libgnome_autoar_la_headers = \
gnome-autoar/autoar-create.h \
- gnome-autoar/autoar-extract.h \
+ gnome-autoar/autoar-extractor.h \
gnome-autoar/autoar-format-filter.h \
gnome-autoar/autoar-misc.h \
gnome-autoar/autoar-pref.h \
$(NULL)
libgnome_autoar_la_sources = \
gnome-autoar/autoar-create.c \
- gnome-autoar/autoar-extract.c \
+ gnome-autoar/autoar-extractor.c \
gnome-autoar/autoar-format-filter.c \
gnome-autoar/autoar-misc.c \
gnome-autoar/autoar-pref.c \
diff --git a/gnome-autoar/autoar-extract.c b/gnome-autoar/autoar-extractor.c
similarity index 56%
rename from gnome-autoar/autoar-extract.c
rename to gnome-autoar/autoar-extractor.c
index fc8fcf5..51e6fd4 100644
--- a/gnome-autoar/autoar-extract.c
+++ b/gnome-autoar/autoar-extractor.c
@@ -1,7 +1,7 @@
/* vim: set sw=2 ts=2 sts=2 et: */
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
- * autoar-extract.c
+ * autoar-extractor.c
* Automatically extract archives in some GNOME programs
*
* Copyright (C) 2013 Ting-Wei Lan
@@ -24,7 +24,7 @@
*/
#include "config.h"
-#include "autoar-extract.h"
+#include "autoar-extractor.h"
#include "autoar-misc.h"
#include "autoar-private.h"
@@ -52,12 +52,12 @@
#endif
/**
- * SECTION:autoar-extract
+ * SECTION:autoar-extractor
* @Short_description: Automatically extract an archive
- * @Title: AutoarExtract
+ * @Title: AutoarExtractor
* @Include: gnome-autoar/autoar.h
*
- * The #AutoarExtract object is used to automatically extract files and
+ * The #AutoarExtractor object is used to automatically extract files and
* directories from an archive. By default, it will only create one file or
* directory in the output directory. This is done to avoid clutter on the
* user's output directory. If the archive contains only one file, the file
@@ -65,34 +65,34 @@
* file, the files will be extracted in a directory having the same name as the
* archive, except the extension. It is also possible to just extract all files
* to the output directory (note that this will not perform any checks) by
- * using autoar_extract_set_output_is_dest().
+ * using autoar_extractor_set_output_is_dest().
- * #AutoarExtract will not attempt to solve any name conflicts. If the
+ * #AutoarExtractor will not attempt to solve any name conflicts. If the
* destination directory already exists, it will proceed normally. If the
* destionation directory cannot be created, it will fail with an error.
* It is possible however to change the destination, when
- * #AutoarExtract::decide-destination is emitted. The signal provides the decided
+ * #AutoarExtractor::decide-destination is emitted. The signal provides the decided
* destination and the list of files to be extracted. The signal also allows a
* new output destination to be used instead of the one provided by
- * #AutoarExtract. This is convenient for solving name conflicts and
+ * #AutoarExtractor. This is convenient for solving name conflicts and
* implementing specific logic based on the contents of the archive.
*
- * When #AutoarExtract stops all work, it will emit one of the three signals:
- * #AutoarExtract::cancelled, #AutoarExtract::error, and
- * #AutoarExtract::completed. After one of these signals is received,
- * the #AutoarExtract object should be destroyed because it cannot be used to
- * start another archive operation. An #AutoarExtract object can only be used
+ * When #AutoarExtractor stops all work, it will emit one of the three signals:
+ * #AutoarExtractor::cancelled, #AutoarExtractor::error, and
+ * #AutoarExtractor::completed. After one of these signals is received,
+ * the #AutoarExtractor object should be destroyed because it cannot be used to
+ * start another archive operation. An #AutoarExtractor object can only be used
* once and extract one archive.
**/
/**
- * autoar_extract_quark:
+ * autoar_extractor_quark:
*
- * Gets the #AutoarExtract Error Quark.
+ * Gets the #AutoarExtractor Error Quark.
*
* Returns: a #GQuark.
**/
-G_DEFINE_QUARK (autoar-extract, autoar_extract)
+G_DEFINE_QUARK (autoar-extractor, autoar_extractor)
#define BUFFER_SIZE (64 * 1024)
#define NOT_AN_ARCHIVE_ERRNO 2013
@@ -100,7 +100,7 @@ G_DEFINE_QUARK (autoar-extract, autoar_extract)
typedef struct _GFileAndInfo GFileAndInfo;
-struct _AutoarExtract
+struct _AutoarExtractor
{
GObject parent_instance;
@@ -147,7 +147,7 @@ struct _AutoarExtract
int use_raw_format : 1;
};
-G_DEFINE_TYPE (AutoarExtract, autoar_extract, G_TYPE_OBJECT)
+G_DEFINE_TYPE (AutoarExtractor, autoar_extractor, G_TYPE_OBJECT)
struct _GFileAndInfo
{
@@ -181,45 +181,45 @@ enum
PROP_NOTIFY_INTERVAL
};
-static guint autoar_extract_signals[LAST_SIGNAL] = { 0 };
+static guint autoar_extractor_signals[LAST_SIGNAL] = { 0 };
static void
-autoar_extract_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+autoar_extractor_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- AutoarExtract *arextract;
+ AutoarExtractor *extractor;
- arextract = AUTOAR_EXTRACT (object);
+ extractor = AUTOAR_EXTRACTOR (object);
switch (property_id) {
case PROP_SOURCE_FILE:
- g_value_set_object (value, arextract->source_file);
+ g_value_set_object (value, extractor->source_file);
break;
case PROP_OUTPUT_FILE:
- g_value_set_object (value, arextract->output_file);
+ g_value_set_object (value, extractor->output_file);
break;
case PROP_SIZE:
- g_value_set_uint64 (value, arextract->size);
+ g_value_set_uint64 (value, extractor->size);
break;
case PROP_COMPLETED_SIZE:
- g_value_set_uint64 (value, arextract->completed_size);
+ g_value_set_uint64 (value, extractor->completed_size);
break;
case PROP_FILES:
- g_value_set_uint (value, arextract->files);
+ g_value_set_uint (value, extractor->files);
break;
case PROP_COMPLETED_FILES:
- g_value_set_uint (value, arextract->completed_files);
+ g_value_set_uint (value, extractor->completed_files);
break;
case PROP_OUTPUT_IS_DEST:
- g_value_set_boolean (value, arextract->output_is_dest);
+ g_value_set_boolean (value, extractor->output_is_dest);
break;
case PROP_DELETE_IF_SUCCEED:
- g_value_set_boolean (value, arextract->delete_if_succeed);
+ g_value_set_boolean (value, extractor->delete_if_succeed);
break;
case PROP_NOTIFY_INTERVAL:
- g_value_set_int64 (value, arextract->notify_interval);
+ g_value_set_int64 (value, extractor->notify_interval);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -228,32 +228,35 @@ autoar_extract_get_property (GObject *object,
}
static void
-autoar_extract_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
+autoar_extractor_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- AutoarExtract *arextract;
+ AutoarExtractor *extractor;
- arextract = AUTOAR_EXTRACT (object);
+ extractor = AUTOAR_EXTRACTOR (object);
switch (property_id) {
case PROP_SOURCE_FILE:
- g_clear_object (&arextract->source_file);
- arextract->source_file = g_object_ref (g_value_get_object (value));
+ g_clear_object (&extractor->source_file);
+ extractor->source_file = g_object_ref (g_value_get_object (value));
break;
case PROP_OUTPUT_FILE:
- g_clear_object (&arextract->output_file);
- arextract->output_file = g_object_ref (g_value_get_object (value));
+ g_clear_object (&extractor->output_file);
+ extractor->output_file = g_object_ref (g_value_get_object (value));
break;
case PROP_OUTPUT_IS_DEST:
- autoar_extract_set_output_is_dest (arextract, g_value_get_boolean (value));
+ autoar_extractor_set_output_is_dest (extractor,
+ g_value_get_boolean (value));
break;
case PROP_DELETE_IF_SUCCEED:
- autoar_extract_set_delete_if_succeed (arextract, g_value_get_boolean (value));
+ autoar_extractor_set_delete_if_succeed (extractor,
+ g_value_get_boolean (value));
break;
case PROP_NOTIFY_INTERVAL:
- autoar_extract_set_notify_interval (arextract, g_value_get_int64 (value));
+ autoar_extractor_set_notify_interval (extractor,
+ g_value_get_int64 (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -262,8 +265,8 @@ autoar_extract_set_property (GObject *object,
}
/**
- * autoar_extract_get_source_file:
- * @arextract: an #AutoarExtract
+ * autoar_extractor_get_source_file:
+ * @extractor: an #AutoarExtractor
*
* Gets the #GFile object which represents the source archive that will be
* extracted for this object.
@@ -271,61 +274,61 @@ autoar_extract_set_property (GObject *object,
* Returns: (transfer none): a #GFile
**/
GFile*
-autoar_extract_get_source_file (AutoarExtract *arextract)
+autoar_extractor_get_source_file (AutoarExtractor *extractor)
{
- g_return_val_if_fail (AUTOAR_IS_EXTRACT (arextract), NULL);
- return arextract->source_file;
+ g_return_val_if_fail (AUTOAR_IS_EXTRACTOR (extractor), NULL);
+ return extractor->source_file;
}
/**
- * autoar_extract_get_output_file:
- * @arextract: an #AutoarExtract
+ * autoar_extractor_get_output_file:
+ * @extractor: an #AutoarExtractor
*
- * This function is similar to autoar_extract_get_output(), except for the
+ * This function is similar to autoar_extractor_get_output(), except for the
* return value is a #GFile.
*
* Returns: (transfer none): a #GFile
**/
GFile*
-autoar_extract_get_output_file (AutoarExtract *arextract)
+autoar_extractor_get_output_file (AutoarExtractor *extractor)
{
- g_return_val_if_fail (AUTOAR_IS_EXTRACT (arextract), NULL);
- return arextract->output_file;
+ g_return_val_if_fail (AUTOAR_IS_EXTRACTOR (extractor), NULL);
+ return extractor->output_file;
}
/**
- * autoar_extract_get_size:
- * @arextract: an #AutoarExtract
+ * autoar_extractor_get_size:
+ * @extractor: an #AutoarExtractor
*
* Gets the size in bytes will be written when the operation is completed.
*
* Returns: total size of extracted files in bytes
**/
guint64
-autoar_extract_get_size (AutoarExtract *arextract)
+autoar_extractor_get_size (AutoarExtractor *extractor)
{
- g_return_val_if_fail (AUTOAR_IS_EXTRACT (arextract), 0);
- return arextract->size;
+ g_return_val_if_fail (AUTOAR_IS_EXTRACTOR (extractor), 0);
+ return extractor->size;
}
/**
- * autoar_extract_get_completed_size:
- * @arextract: an #AutoarExtract
+ * autoar_extractor_get_completed_size:
+ * @extractor: an #AutoarExtractor
*
* Gets the size in bytes has been written to disk.
*
* Returns: size in bytes has been written
**/
guint64
-autoar_extract_get_completed_size (AutoarExtract *arextract)
+autoar_extractor_get_completed_size (AutoarExtractor *extractor)
{
- g_return_val_if_fail (AUTOAR_IS_EXTRACT (arextract), 0);
- return arextract->completed_size;
+ g_return_val_if_fail (AUTOAR_IS_EXTRACTOR (extractor), 0);
+ return extractor->completed_size;
}
/**
- * autoar_extract_get_files:
- * @arextract: an #AutoarExtract
+ * autoar_extractor_get_files:
+ * @extractor: an #AutoarExtractor
*
* Gets the total number of files will be written when the operation is
* completed.
@@ -333,46 +336,46 @@ autoar_extract_get_completed_size (AutoarExtract *arextract)
* Returns: total number of extracted files
**/
guint
-autoar_extract_get_files (AutoarExtract *arextract)
+autoar_extractor_get_files (AutoarExtractor *extractor)
{
- g_return_val_if_fail (AUTOAR_IS_EXTRACT (arextract), 0);
- return arextract->files;
+ g_return_val_if_fail (AUTOAR_IS_EXTRACTOR (extractor), 0);
+ return extractor->files;
}
/**
- * autoar_extract_get_completed_files:
- * @arextract: an #AutoarExtract
+ * autoar_extractor_get_completed_files:
+ * @extractor: an #AutoarExtractor
*
* Gets the number of files has been written to disk.
*
* Returns: number of files has been written to disk
**/
guint
-autoar_extract_get_completed_files (AutoarExtract *arextract)
+autoar_extractor_get_completed_files (AutoarExtractor *extractor)
{
- g_return_val_if_fail (AUTOAR_IS_EXTRACT (arextract), 0);
- return arextract->completed_files;
+ g_return_val_if_fail (AUTOAR_IS_EXTRACTOR (extractor), 0);
+ return extractor->completed_files;
}
/**
- * autoar_extract_get_output_is_dest:
- * @arextract: an #AutoarExtract
+ * autoar_extractor_get_output_is_dest:
+ * @extractor: an #AutoarExtractor
*
- * See autoar_extract_set_output_is_dest().
+ * See autoar_extractor_set_output_is_dest().
*
- * Returns: %TRUE if #AutoarExtract:output is the location of extracted file
+ * Returns: %TRUE if #AutoarExtractor:output is the location of extracted file
* or directory
**/
gboolean
-autoar_extract_get_output_is_dest (AutoarExtract *arextract)
+autoar_extractor_get_output_is_dest (AutoarExtractor *extractor)
{
- g_return_val_if_fail (AUTOAR_IS_EXTRACT (arextract), FALSE);
- return arextract->output_is_dest;
+ g_return_val_if_fail (AUTOAR_IS_EXTRACTOR (extractor), FALSE);
+ return extractor->output_is_dest;
}
/**
- * autoar_extract_get_delete_if_succeed:
- * @arextract: an #AutoarExtract
+ * autoar_extractor_get_delete_if_succeed:
+ * @extractor: an #AutoarExtractor
*
* Whether the source archive will be deleted after a successful extraction.
*
@@ -380,180 +383,180 @@ autoar_extract_get_output_is_dest (AutoarExtract *arextract)
* extraction
**/
gboolean
-autoar_extract_get_delete_if_succeed (AutoarExtract *arextract)
+autoar_extractor_get_delete_if_succeed (AutoarExtractor *extractor)
{
- g_return_val_if_fail (AUTOAR_IS_EXTRACT (arextract), FALSE);
- return arextract->delete_if_succeed;
+ g_return_val_if_fail (AUTOAR_IS_EXTRACTOR (extractor), FALSE);
+ return extractor->delete_if_succeed;
}
/**
- * autoar_extract_get_notify_interval:
- * @arextract: an #AutoarExtract
+ * autoar_extractor_get_notify_interval:
+ * @extractor: an #AutoarExtractor
*
- * See autoar_extract_set_notify_interval().
+ * See autoar_extractor_set_notify_interval().
*
* Returns: the minimal interval in microseconds between the emission of the
- * #AutoarExtract::progress signal.
+ * #AutoarExtractor::progress signal.
**/
gint64
-autoar_extract_get_notify_interval (AutoarExtract *arextract)
+autoar_extractor_get_notify_interval (AutoarExtractor *extractor)
{
- g_return_val_if_fail (AUTOAR_IS_EXTRACT (arextract), 0);
- return arextract->notify_interval;
+ g_return_val_if_fail (AUTOAR_IS_EXTRACTOR (extractor), 0);
+ return extractor->notify_interval;
}
/**
- * autoar_extract_set_output_is_dest:
- * @arextract: an #AutoarExtract
+ * autoar_extractor_set_output_is_dest:
+ * @extractor: an #AutoarExtractor
* @output_is_dest: %TRUE if the location of the extracted directory or file
* has been already decided
*
- * By default #AutoarExtract:output-is-dest is set to %FALSE, which means
+ * By default #AutoarExtractor:output-is-dest is set to %FALSE, which means
* only one file or directory will be generated. The destination is internally
* determined by analyzing the contents of the archive. If this is not wanted,
- * #AutoarExtract:output-is-dest can be set to %TRUE, which will make
- * #AutoarExtract:output the destination for extracted files. In any case, the
- * destination directory will be notified via #AutoarExtract::decide-destination,
+ * #AutoarExtractor:output-is-dest can be set to %TRUE, which will make
+ * #AutoarExtractor:output the destination for extracted files. In any case, the
+ * destination directory will be notified via #AutoarExtractor::decide-destination,
* when it is possible to set a new destination.
*
- * #AutoarExtract will attempt to create the destination directory regardless
+ * #AutoarExtractor will attempt to create the destination directory regardless
* to whether its path was internally decided or not.
- * This function should only be called before calling autoar_extract_start() or
- * autoar_extract_start_async().
+ * This function should only be called before calling autoar_extractor_start() or
+ * autoar_extractor_start_async().
**/
void
-autoar_extract_set_output_is_dest (AutoarExtract *arextract,
- gboolean output_is_dest)
+autoar_extractor_set_output_is_dest (AutoarExtractor *extractor,
+ gboolean output_is_dest)
{
- g_return_if_fail (AUTOAR_IS_EXTRACT (arextract));
- arextract->output_is_dest = output_is_dest;
+ g_return_if_fail (AUTOAR_IS_EXTRACTOR (extractor));
+ extractor->output_is_dest = output_is_dest;
}
/**
- * autoar_extract_set_delete_if_succeed:
- * @arextract: an #AutoarExtract
+ * autoar_extractor_set_delete_if_succeed:
+ * @extractor: an #AutoarExtractor
* @delete_if_succeed: %TRUE if the source archive should be deleted after a
* successful extraction
*
- * By default #AutoarExtract:delete-if-succeed is set to %FALSE so the source
+ * By default #AutoarExtractor:delete-if-succeed is set to %FALSE so the source
* archive will not be automatically deleted if extraction succeeds.
**/
void
-autoar_extract_set_delete_if_succeed (AutoarExtract *arextract,
- gboolean delete_if_succeed)
+autoar_extractor_set_delete_if_succeed (AutoarExtractor *extractor,
+ gboolean delete_if_succeed)
{
- g_return_if_fail (AUTOAR_IS_EXTRACT (arextract));
- arextract->delete_if_succeed = delete_if_succeed;
+ g_return_if_fail (AUTOAR_IS_EXTRACTOR (extractor));
+ extractor->delete_if_succeed = delete_if_succeed;
}
/**
- * autoar_extract_set_notify_interval:
- * @arextract: an #AutoarExtract
+ * autoar_extractor_set_notify_interval:
+ * @extractor: an #AutoarExtractor
* @notify_interval: the minimal interval in microseconds
*
- * Sets the minimal interval between emission of #AutoarExtract::progress
+ * Sets the minimal interval between emission of #AutoarExtractor::progress
* signal. This prevent too frequent signal emission, which may cause
* performance impact. If you do not want this feature, you can set the interval
* to 0, so you will receive every progress update.
**/
void
-autoar_extract_set_notify_interval (AutoarExtract *arextract,
- gint64 notify_interval)
+autoar_extractor_set_notify_interval (AutoarExtractor *extractor,
+ gint64 notify_interval)
{
- g_return_if_fail (AUTOAR_IS_EXTRACT (arextract));
+ g_return_if_fail (AUTOAR_IS_EXTRACTOR (extractor));
g_return_if_fail (notify_interval >= 0);
- arextract->notify_interval = notify_interval;
+ extractor->notify_interval = notify_interval;
}
static void
-autoar_extract_dispose (GObject *object)
+autoar_extractor_dispose (GObject *object)
{
- AutoarExtract *arextract;
+ AutoarExtractor *extractor;
- arextract = AUTOAR_EXTRACT (object);
+ extractor = AUTOAR_EXTRACTOR (object);
- g_debug ("AutoarExtract: dispose");
+ g_debug ("AutoarExtractor: dispose");
- if (arextract->istream != NULL) {
- if (!g_input_stream_is_closed (arextract->istream)) {
- g_input_stream_close (arextract->istream, arextract->cancellable, NULL);
+ if (extractor->istream != NULL) {
+ if (!g_input_stream_is_closed (extractor->istream)) {
+ g_input_stream_close (extractor->istream, extractor->cancellable, NULL);
}
- g_object_unref (arextract->istream);
- arextract->istream = NULL;
+ g_object_unref (extractor->istream);
+ extractor->istream = NULL;
}
- g_clear_object (&(arextract->source_file));
- g_clear_object (&(arextract->output_file));
- g_clear_object (&(arextract->destination_dir));
- g_clear_object (&(arextract->cancellable));
- g_clear_object (&(arextract->prefix));
- g_clear_object (&(arextract->new_prefix));
+ g_clear_object (&(extractor->source_file));
+ g_clear_object (&(extractor->output_file));
+ g_clear_object (&(extractor->destination_dir));
+ g_clear_object (&(extractor->cancellable));
+ g_clear_object (&(extractor->prefix));
+ g_clear_object (&(extractor->new_prefix));
- g_list_free_full (arextract->files_list, g_object_unref);
- arextract->files_list = NULL;
+ g_list_free_full (extractor->files_list, g_object_unref);
+ extractor->files_list = NULL;
- if (arextract->userhash != NULL) {
- g_hash_table_unref (arextract->userhash);
- arextract->userhash = NULL;
+ if (extractor->userhash != NULL) {
+ g_hash_table_unref (extractor->userhash);
+ extractor->userhash = NULL;
}
- if (arextract->grouphash != NULL) {
- g_hash_table_unref (arextract->grouphash);
- arextract->grouphash = NULL;
+ if (extractor->grouphash != NULL) {
+ g_hash_table_unref (extractor->grouphash);
+ extractor->grouphash = NULL;
}
- if (arextract->extracted_dir_list != NULL) {
- g_array_unref (arextract->extracted_dir_list);
- arextract->extracted_dir_list = NULL;
+ if (extractor->extracted_dir_list != NULL) {
+ g_array_unref (extractor->extracted_dir_list);
+ extractor->extracted_dir_list = NULL;
}
- G_OBJECT_CLASS (autoar_extract_parent_class)->dispose (object);
+ G_OBJECT_CLASS (autoar_extractor_parent_class)->dispose (object);
}
static void
-autoar_extract_finalize (GObject *object)
+autoar_extractor_finalize (GObject *object)
{
- AutoarExtract *arextract;
+ AutoarExtractor *extractor;
- arextract = AUTOAR_EXTRACT (object);
+ extractor = AUTOAR_EXTRACTOR (object);
- g_debug ("AutoarExtract: finalize");
+ g_debug ("AutoarExtractor: finalize");
- g_free (arextract->buffer);
- arextract->buffer = NULL;
+ g_free (extractor->buffer);
+ extractor->buffer = NULL;
- if (arextract->error != NULL) {
- g_error_free (arextract->error);
- arextract->error = NULL;
+ if (extractor->error != NULL) {
+ g_error_free (extractor->error);
+ extractor->error = NULL;
}
- g_free (arextract->suggested_destname);
- arextract->suggested_destname = NULL;
+ g_free (extractor->suggested_destname);
+ extractor->suggested_destname = NULL;
- G_OBJECT_CLASS (autoar_extract_parent_class)->finalize (object);
+ G_OBJECT_CLASS (autoar_extractor_parent_class)->finalize (object);
}
static int
libarchive_read_open_cb (struct archive *ar_read,
void *client_data)
{
- AutoarExtract *arextract;
+ AutoarExtractor *extractor;
GFileInputStream *istream;
g_debug ("libarchive_read_open_cb: called");
- arextract = (AutoarExtract*)client_data;
+ extractor = (AutoarExtractor*)client_data;
- if (arextract->error != NULL)
+ if (extractor->error != NULL)
return ARCHIVE_FATAL;
- istream = g_file_read (arextract->source_file,
- arextract->cancellable,
- &(arextract->error));
- arextract->istream = G_INPUT_STREAM (istream);
+ istream = g_file_read (extractor->source_file,
+ extractor->cancellable,
+ &(extractor->error));
+ extractor->istream = G_INPUT_STREAM (istream);
- if (arextract->error != NULL)
+ if (extractor->error != NULL)
return ARCHIVE_FATAL;
g_debug ("libarchive_read_open_cb: ARCHIVE_OK");
@@ -564,19 +567,19 @@ static int
libarchive_read_close_cb (struct archive *ar_read,
void *client_data)
{
- AutoarExtract *arextract;
+ AutoarExtractor *extractor;
g_debug ("libarchive_read_close_cb: called");
- arextract = AUTOAR_EXTRACT (client_data);
+ extractor = AUTOAR_EXTRACTOR (client_data);
- if (arextract->error != NULL)
+ if (extractor->error != NULL)
return ARCHIVE_FATAL;
- if (arextract->istream != NULL) {
- g_input_stream_close (arextract->istream, arextract->cancellable, NULL);
- g_object_unref (arextract->istream);
- arextract->istream = NULL;
+ if (extractor->istream != NULL) {
+ g_input_stream_close (extractor->istream, extractor->cancellable, NULL);
+ g_object_unref (extractor->istream);
+ extractor->istream = NULL;
}
g_debug ("libarchive_read_close_cb: ARCHIVE_OK");
@@ -588,23 +591,23 @@ libarchive_read_read_cb (struct archive *ar_read,
void *client_data,
const void **buffer)
{
- AutoarExtract *arextract;
+ AutoarExtractor *extractor;
gssize read_size;
g_debug ("libarchive_read_read_cb: called");
- arextract = AUTOAR_EXTRACT (client_data);
+ extractor = AUTOAR_EXTRACTOR (client_data);
- if (arextract->error != NULL || arextract->istream == NULL)
+ if (extractor->error != NULL || extractor->istream == NULL)
return -1;
- *buffer = arextract->buffer;
- read_size = g_input_stream_read (arextract->istream,
- arextract->buffer,
- arextract->buffer_size,
- arextract->cancellable,
- &(arextract->error));
- if (arextract->error != NULL)
+ *buffer = extractor->buffer;
+ read_size = g_input_stream_read (extractor->istream,
+ extractor->buffer,
+ extractor->buffer_size,
+ extractor->cancellable,
+ &(extractor->error));
+ if (extractor->error != NULL)
return -1;
g_debug ("libarchive_read_read_cb: %" G_GSSIZE_FORMAT, read_size);
@@ -617,16 +620,16 @@ libarchive_read_seek_cb (struct archive *ar_read,
gint64 request,
int whence)
{
- AutoarExtract *arextract;
+ AutoarExtractor *extractor;
GSeekable *seekable;
GSeekType seektype;
off_t new_offset;
g_debug ("libarchive_read_seek_cb: called");
- arextract = AUTOAR_EXTRACT (client_data);
- seekable = (GSeekable*)(arextract->istream);
- if (arextract->error != NULL || arextract->istream == NULL)
+ extractor = AUTOAR_EXTRACTOR (client_data);
+ seekable = (GSeekable*)(extractor->istream);
+ if (extractor->error != NULL || extractor->istream == NULL)
return -1;
switch (whence) {
@@ -646,10 +649,10 @@ libarchive_read_seek_cb (struct archive *ar_read,
g_seekable_seek (seekable,
request,
seektype,
- arextract->cancellable,
- &(arextract->error));
+ extractor->cancellable,
+ &(extractor->error));
new_offset = g_seekable_tell (seekable);
- if (arextract->error != NULL)
+ if (extractor->error != NULL)
return -1;
g_debug ("libarchive_read_seek_cb: %"G_GOFFSET_FORMAT, (goffset)new_offset);
@@ -661,15 +664,15 @@ libarchive_read_skip_cb (struct archive *ar_read,
void *client_data,
gint64 request)
{
- AutoarExtract *arextract;
+ AutoarExtractor *extractor;
GSeekable *seekable;
off_t old_offset, new_offset;
g_debug ("libarchive_read_skip_cb: called");
- arextract = AUTOAR_EXTRACT (client_data);
- seekable = (GSeekable*)(arextract->istream);
- if (arextract->error != NULL || arextract->istream == NULL) {
+ extractor = AUTOAR_EXTRACTOR (client_data);
+ seekable = (GSeekable*)(extractor->istream);
+ if (extractor->error != NULL || extractor->istream == NULL) {
return -1;
}
@@ -683,7 +686,7 @@ libarchive_read_skip_cb (struct archive *ar_read,
static int
libarchive_create_read_object (gboolean use_raw_format,
- AutoarExtract *arextract,
+ AutoarExtractor *extractor,
struct archive **a)
{
*a = archive_read_new ();
@@ -697,7 +700,7 @@ libarchive_create_read_object (gboolean use_raw_format,
archive_read_set_close_callback (*a, libarchive_read_close_cb);
archive_read_set_seek_callback (*a, libarchive_read_seek_cb);
archive_read_set_skip_callback (*a, libarchive_read_skip_cb);
- archive_read_set_callback_data (*a, arextract);
+ archive_read_set_callback_data (*a, extractor);
return archive_read_open1 (*a);
}
@@ -711,49 +714,49 @@ g_file_and_info_free (void *g_file_and_info)
}
static inline void
-autoar_extract_signal_scanned (AutoarExtract *arextract)
+autoar_extractor_signal_scanned (AutoarExtractor *extractor)
{
- autoar_common_g_signal_emit (arextract, arextract->in_thread,
- autoar_extract_signals[SCANNED], 0,
- arextract->files);
+ autoar_common_g_signal_emit (extractor, extractor->in_thread,
+ autoar_extractor_signals[SCANNED], 0,
+ extractor->files);
}
static inline void
-autoar_extract_signal_decide_destination (AutoarExtract *arextract,
- GFile *destination,
- GList *files,
- GFile **new_destination)
+autoar_extractor_signal_decide_destination (AutoarExtractor *extractor,
+ GFile *destination,
+ GList *files,
+ GFile **new_destination)
{
- autoar_common_g_signal_emit (arextract, arextract->in_thread,
- autoar_extract_signals[DECIDE_DESTINATION], 0,
+ autoar_common_g_signal_emit (extractor, extractor->in_thread,
+ autoar_extractor_signals[DECIDE_DESTINATION], 0,
destination,
files,
new_destination);
}
static inline void
-autoar_extract_signal_progress (AutoarExtract *arextract)
+autoar_extractor_signal_progress (AutoarExtractor *extractor)
{
gint64 mtime;
mtime = g_get_monotonic_time ();
- if (mtime - arextract->notify_last >= arextract->notify_interval) {
- autoar_common_g_signal_emit (arextract, arextract->in_thread,
- autoar_extract_signals[PROGRESS], 0,
- arextract->completed_size,
- arextract->completed_files);
- arextract->notify_last = mtime;
+ if (mtime - extractor->notify_last >= extractor->notify_interval) {
+ autoar_common_g_signal_emit (extractor, extractor->in_thread,
+ autoar_extractor_signals[PROGRESS], 0,
+ extractor->completed_size,
+ extractor->completed_files);
+ extractor->notify_last = mtime;
}
}
static AutoarConflictAction
-autoar_extract_signal_conflict (AutoarExtract *arextract,
- GFile *file,
- GFile **new_file)
+autoar_extractor_signal_conflict (AutoarExtractor *extractor,
+ GFile *file,
+ GFile **new_file)
{
AutoarConflictAction action = AUTOAR_CONFLICT_OVERWRITE;
- autoar_common_g_signal_emit (arextract, arextract->in_thread,
- autoar_extract_signals[CONFLICT], 0,
+ autoar_common_g_signal_emit (extractor, extractor->in_thread,
+ autoar_extractor_signals[CONFLICT], 0,
file,
new_file,
&action);
@@ -764,48 +767,49 @@ autoar_extract_signal_conflict (AutoarExtract *arextract,
previous_path = g_file_get_path (file);
new_path = g_file_get_path (*new_file);
- g_debug ("autoar_extract_signal_conflict: %s => %s", previous_path, new_path);
+ g_debug ("autoar_extractor_signal_conflict: %s => %s",
+ previous_path, new_path);
}
return action;
}
static inline void
-autoar_extract_signal_cancelled (AutoarExtract *arextract)
+autoar_extractor_signal_cancelled (AutoarExtractor *extractor)
{
- autoar_common_g_signal_emit (arextract, arextract->in_thread,
- autoar_extract_signals[CANCELLED], 0);
+ autoar_common_g_signal_emit (extractor, extractor->in_thread,
+ autoar_extractor_signals[CANCELLED], 0);
}
static inline void
-autoar_extract_signal_completed (AutoarExtract *arextract)
+autoar_extractor_signal_completed (AutoarExtractor *extractor)
{
- autoar_common_g_signal_emit (arextract, arextract->in_thread,
- autoar_extract_signals[COMPLETED], 0);
+ autoar_common_g_signal_emit (extractor, extractor->in_thread,
+ autoar_extractor_signals[COMPLETED], 0);
}
static inline void
-autoar_extract_signal_error (AutoarExtract *arextract)
+autoar_extractor_signal_error (AutoarExtractor *extractor)
{
- if (arextract->error != NULL) {
- if (arextract->error->domain == G_IO_ERROR &&
- arextract->error->code == G_IO_ERROR_CANCELLED) {
- g_error_free (arextract->error);
- arextract->error = NULL;
- autoar_extract_signal_cancelled (arextract);
+ if (extractor->error != NULL) {
+ if (extractor->error->domain == G_IO_ERROR &&
+ extractor->error->code == G_IO_ERROR_CANCELLED) {
+ g_error_free (extractor->error);
+ extractor->error = NULL;
+ autoar_extractor_signal_cancelled (extractor);
} else {
- autoar_common_g_signal_emit (arextract, arextract->in_thread,
- autoar_extract_signals[AR_ERROR], 0,
- arextract->error);
+ autoar_common_g_signal_emit (extractor, extractor->in_thread,
+ autoar_extractor_signals[AR_ERROR], 0,
+ extractor->error);
}
}
}
static GFile*
-autoar_extract_get_common_prefix (GList *files,
- GFile *root)
+autoar_extractor_get_common_prefix (GList *files,
+ GFile *root)
{
GFile *prefix;
GFile *file;
@@ -837,16 +841,17 @@ autoar_extract_get_common_prefix (GList *files,
}
static GFile*
-autoar_extract_do_sanitize_pathname (AutoarExtract *arextract,
- const char *pathname)
+autoar_extractor_do_sanitize_pathname (AutoarExtractor *extractor,
+ const char *pathname)
{
GFile *extracted_filename;
gboolean valid_filename;
- extracted_filename = g_file_get_child (arextract->destination_dir, pathname);
+ extracted_filename = g_file_get_child (extractor->destination_dir, pathname);
- valid_filename = g_file_equal (extracted_filename, arextract->destination_dir) ||
- g_file_has_prefix (extracted_filename, arextract->destination_dir);
+ valid_filename =
+ g_file_equal (extracted_filename, extractor->destination_dir) ||
+ g_file_has_prefix (extracted_filename, extractor->destination_dir);
if (!valid_filename) {
g_autofree char *basename;
@@ -855,21 +860,22 @@ autoar_extract_do_sanitize_pathname (AutoarExtract *arextract,
g_object_unref (extracted_filename);
- extracted_filename = g_file_get_child (arextract->destination_dir,
+ extracted_filename = g_file_get_child (extractor->destination_dir,
basename);
}
- if (arextract->prefix != NULL && arextract->new_prefix != NULL) {
+ if (extractor->prefix != NULL && extractor->new_prefix != NULL) {
g_autofree char *relative_path;
/* Replace the old prefix with the new one */
- relative_path = g_file_get_relative_path (arextract->prefix,
+ relative_path = g_file_get_relative_path (extractor->prefix,
extracted_filename);
relative_path = relative_path != NULL ? relative_path : g_strdup ("");
g_object_unref (extracted_filename);
- extracted_filename = g_file_get_child (arextract->new_prefix, relative_path);
+ extracted_filename = g_file_get_child (extractor->new_prefix,
+ relative_path);
}
{
@@ -877,15 +883,15 @@ autoar_extract_do_sanitize_pathname (AutoarExtract *arextract,
sanitized_pathname = g_file_get_path (extracted_filename);
- g_debug ("autoar_extract_do_sanitize_pathname: %s", sanitized_pathname);
+ g_debug ("autoar_extractor_do_sanitize_pathname: %s", sanitized_pathname);
}
return extracted_filename;
}
static gboolean
-autoar_extract_check_file_conflict (GFile *file,
- mode_t extracted_filetype)
+autoar_extractor_check_file_conflict (GFile *file,
+ mode_t extracted_filetype)
{
GFileType file_type;
gboolean conflict = FALSE;
@@ -921,11 +927,11 @@ autoar_extract_check_file_conflict (GFile *file,
}
static void
-autoar_extract_do_write_entry (AutoarExtract *arextract,
- struct archive *a,
- struct archive_entry *entry,
- GFile *dest,
- GFile *hardlink)
+autoar_extractor_do_write_entry (AutoarExtractor *extractor,
+ struct archive *a,
+ struct archive_entry *entry,
+ GFile *dest,
+ GFile *hardlink)
{
GFileInfo *info;
mode_t filetype;
@@ -934,15 +940,17 @@ autoar_extract_do_write_entry (AutoarExtract *arextract,
{
GFile *parent;
parent = g_file_get_parent (dest);
- if (!g_file_query_exists (parent, arextract->cancellable))
- g_file_make_directory_with_parents (parent, arextract->cancellable, NULL);
+ if (!g_file_query_exists (parent, extractor->cancellable))
+ g_file_make_directory_with_parents (parent,
+ extractor->cancellable,
+ NULL);
g_object_unref (parent);
}
info = g_file_info_new ();
/* time */
- g_debug ("autoar_extract_do_write_entry: time");
+ g_debug ("autoar_extractor_do_write_entry: time");
if (archive_entry_atime_is_set (entry)) {
g_file_info_set_attribute_uint64 (info,
G_FILE_ATTRIBUTE_TIME_ACCESS,
@@ -981,11 +989,11 @@ autoar_extract_do_write_entry (AutoarExtract *arextract,
guint32 uid;
const char *uname;
- g_debug ("autoar_extract_do_write_entry: user");
+ g_debug ("autoar_extractor_do_write_entry: user");
#ifdef HAVE_GETPWNAM
if ((uname = archive_entry_uname (entry)) != NULL) {
void *got_uid;
- if (g_hash_table_lookup_extended (arextract->userhash, uname, NULL, &got_uid) == TRUE) {
+ if (g_hash_table_lookup_extended (extractor->userhash, uname, NULL, &got_uid) == TRUE) {
uid = GPOINTER_TO_UINT (got_uid);
} else {
struct passwd *pwd = getpwnam (uname);
@@ -993,7 +1001,7 @@ autoar_extract_do_write_entry (AutoarExtract *arextract,
uid = archive_entry_uid (entry);
} else {
uid = pwd->pw_uid;
- g_hash_table_insert (arextract->userhash, g_strdup (uname), GUINT_TO_POINTER (uid));
+ g_hash_table_insert (extractor->userhash, g_strdup (uname), GUINT_TO_POINTER (uid));
}
}
g_file_info_set_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_UID, uid);
@@ -1010,11 +1018,11 @@ autoar_extract_do_write_entry (AutoarExtract *arextract,
guint32 gid;
const char *gname;
- g_debug ("autoar_extract_do_write_entry: group");
+ g_debug ("autoar_extractor_do_write_entry: group");
#ifdef HAVE_GETGRNAM
if ((gname = archive_entry_gname (entry)) != NULL) {
void *got_gid;
- if (g_hash_table_lookup_extended (arextract->grouphash, gname, NULL, &got_gid) == TRUE) {
+ if (g_hash_table_lookup_extended (extractor->grouphash, gname, NULL, &got_gid) == TRUE) {
gid = GPOINTER_TO_UINT (got_gid);
} else {
struct group *grp = getgrnam (gname);
@@ -1022,7 +1030,7 @@ autoar_extract_do_write_entry (AutoarExtract *arextract,
gid = archive_entry_gid (entry);
} else {
gid = grp->gr_gid;
- g_hash_table_insert (arextract->grouphash, g_strdup (gname), GUINT_TO_POINTER (gid));
+ g_hash_table_insert (extractor->grouphash, g_strdup (gname), GUINT_TO_POINTER (gid));
}
}
g_file_info_set_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_GID, gid);
@@ -1035,7 +1043,7 @@ autoar_extract_do_write_entry (AutoarExtract *arextract,
}
/* permissions */
- g_debug ("autoar_extract_do_write_entry: permissions");
+ g_debug ("autoar_extractor_do_write_entry: permissions");
g_file_info_set_attribute_uint32 (info,
G_FILE_ATTRIBUTE_UNIX_MODE,
archive_entry_perm (entry));
@@ -1045,18 +1053,18 @@ autoar_extract_do_write_entry (AutoarExtract *arextract,
char *hardlink_path, *dest_path;
r = link (hardlink_path = g_file_get_path (hardlink),
dest_path = g_file_get_path (dest));
- g_debug ("autoar_extract_do_write_entry: hard link, %s => %s, %d",
+ g_debug ("autoar_extractor_do_write_entry: hard link, %s => %s, %d",
dest_path, hardlink_path, r);
g_free (hardlink_path);
g_free (dest_path);
if (r >= 0) {
- g_debug ("autoar_extract_do_write_entry: skip file creation");
+ g_debug ("autoar_extractor_do_write_entry: skip file creation");
goto applyinfo;
}
}
#endif
- g_debug ("autoar_extract_do_write_entry: writing");
+ g_debug ("autoar_extractor_do_write_entry: writing");
r = 0;
switch (filetype = archive_entry_filetype (entry)) {
@@ -1068,22 +1076,22 @@ autoar_extract_do_write_entry (AutoarExtract *arextract,
size_t size, written;
gint64 offset;
- g_debug ("autoar_extract_do_write_entry: case REG");
+ g_debug ("autoar_extractor_do_write_entry: case REG");
ostream = (GOutputStream*)g_file_replace (dest,
NULL,
FALSE,
G_FILE_CREATE_NONE,
- arextract->cancellable,
- &(arextract->error));
- if (arextract->error != NULL) {
+ extractor->cancellable,
+ &(extractor->error));
+ if (extractor->error != NULL) {
g_object_unref (info);
return;
}
if (ostream != NULL) {
/* Archive entry size may be zero if we use raw format. */
- if (archive_entry_size(entry) > 0 || arextract->use_raw_format) {
+ if (archive_entry_size(entry) > 0 || extractor->use_raw_format) {
while (archive_read_data_block (a, &buffer, &size, &offset) == ARCHIVE_OK) {
/* buffer == NULL occurs in some zip archives when an entry is
* completely read. We just skip this situation to prevent GIO
@@ -1094,25 +1102,25 @@ autoar_extract_do_write_entry (AutoarExtract *arextract,
buffer,
size,
&written,
- arextract->cancellable,
- &(arextract->error));
- if (arextract->error != NULL) {
- g_output_stream_close (ostream, arextract->cancellable, NULL);
+ extractor->cancellable,
+ &(extractor->error));
+ if (extractor->error != NULL) {
+ g_output_stream_close (ostream, extractor->cancellable, NULL);
g_object_unref (ostream);
g_object_unref (info);
return;
}
- if (g_cancellable_is_cancelled (arextract->cancellable)) {
- g_output_stream_close (ostream, arextract->cancellable, NULL);
+ if (g_cancellable_is_cancelled (extractor->cancellable)) {
+ g_output_stream_close (ostream, extractor->cancellable, NULL);
g_object_unref (ostream);
g_object_unref (info);
return;
}
- arextract->completed_size += written;
- autoar_extract_signal_progress (arextract);
+ extractor->completed_size += written;
+ autoar_extractor_signal_progress (extractor);
}
}
- g_output_stream_close (ostream, arextract->cancellable, NULL);
+ g_output_stream_close (ostream, extractor->cancellable, NULL);
g_object_unref (ostream);
}
}
@@ -1121,11 +1129,11 @@ autoar_extract_do_write_entry (AutoarExtract *arextract,
{
GFileAndInfo fileandinfo;
- g_debug ("autoar_extract_do_write_entry: case DIR");
+ g_debug ("autoar_extractor_do_write_entry: case DIR");
- g_file_make_directory_with_parents (dest, arextract->cancellable, &(arextract->error));
+ g_file_make_directory_with_parents (dest, extractor->cancellable, &(extractor->error));
- if (arextract->error != NULL) {
+ if (extractor->error != NULL) {
/* "File exists" is not a fatal error, as long as the existing file
* is a directory
*/
@@ -1135,9 +1143,9 @@ autoar_extract_do_write_entry (AutoarExtract *arextract,
G_FILE_QUERY_INFO_NONE,
NULL);
- if (g_error_matches (arextract->error, G_IO_ERROR, G_IO_ERROR_EXISTS) &&
+ if (g_error_matches (extractor->error, G_IO_ERROR, G_IO_ERROR_EXISTS) &&
file_type == G_FILE_TYPE_DIRECTORY) {
- g_clear_error (&arextract->error);
+ g_clear_error (&extractor->error);
} else {
g_object_unref (info);
return;
@@ -1146,15 +1154,15 @@ autoar_extract_do_write_entry (AutoarExtract *arextract,
fileandinfo.file = g_object_ref (dest);
fileandinfo.info = g_object_ref (info);
- g_array_append_val (arextract->extracted_dir_list, fileandinfo);
+ g_array_append_val (extractor->extracted_dir_list, fileandinfo);
}
break;
case AE_IFLNK:
- g_debug ("autoar_extract_do_write_entry: case LNK");
+ g_debug ("autoar_extractor_do_write_entry: case LNK");
g_file_make_symbolic_link (dest,
archive_entry_symlink (entry),
- arextract->cancellable,
- &(arextract->error));
+ extractor->cancellable,
+ &(extractor->error));
break;
/* FIFOs, sockets, block files, character files are not important
* in the regular archives, so errors are not fatal. */
@@ -1162,7 +1170,7 @@ autoar_extract_do_write_entry (AutoarExtract *arextract,
case AE_IFIFO:
{
char *path;
- g_debug ("autoar_extract_do_write_entry: case FIFO");
+ g_debug ("autoar_extractor_do_write_entry: case FIFO");
# ifdef HAVE_MKFIFO
r = mkfifo (path = g_file_get_path (dest), archive_entry_perm (entry));
# else
@@ -1178,7 +1186,7 @@ autoar_extract_do_write_entry (AutoarExtract *arextract,
case AE_IFSOCK:
{
char *path;
- g_debug ("autoar_extract_do_write_entry: case SOCK");
+ g_debug ("autoar_extractor_do_write_entry: case SOCK");
r = mknod (path = g_file_get_path (dest),
S_IFSOCK | archive_entry_perm (entry),
0);
@@ -1188,7 +1196,7 @@ autoar_extract_do_write_entry (AutoarExtract *arextract,
case AE_IFBLK:
{
char *path;
- g_debug ("autoar_extract_do_write_entry: case BLK");
+ g_debug ("autoar_extractor_do_write_entry: case BLK");
r = mknod (path = g_file_get_path (dest),
S_IFBLK | archive_entry_perm (entry),
archive_entry_rdev (entry));
@@ -1198,7 +1206,7 @@ autoar_extract_do_write_entry (AutoarExtract *arextract,
case AE_IFCHR:
{
char *path;
- g_debug ("autoar_extract_do_write_entry: case CHR");
+ g_debug ("autoar_extractor_do_write_entry: case CHR");
r = mknod (path = g_file_get_path (dest),
S_IFCHR | archive_entry_perm (entry),
archive_entry_rdev (entry));
@@ -1215,33 +1223,33 @@ autoar_extract_do_write_entry (AutoarExtract *arextract,
filetype == AE_IFBLK ||
filetype == AE_IFCHR)) {
GOutputStream *ostream;
- ostream = (GOutputStream*)g_file_append_to (dest, G_FILE_CREATE_NONE, arextract->cancellable, NULL);
+ ostream = (GOutputStream*)g_file_append_to (dest, G_FILE_CREATE_NONE, extractor->cancellable, NULL);
if (ostream != NULL) {
- g_output_stream_close (ostream, arextract->cancellable, NULL);
+ g_output_stream_close (ostream, extractor->cancellable, NULL);
g_object_unref (ostream);
}
}
#endif
applyinfo:
- g_debug ("autoar_extract_do_write_entry: applying info");
+ g_debug ("autoar_extractor_do_write_entry: applying info");
g_file_set_attributes_from_info (dest,
info,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
- arextract->cancellable,
- &(arextract->error));
+ extractor->cancellable,
+ &(extractor->error));
- if (arextract->error != NULL) {
- g_debug ("autoar_extract_do_write_entry: %s\n", arextract->error->message);
- g_error_free (arextract->error);
- arextract->error = NULL;
+ if (extractor->error != NULL) {
+ g_debug ("autoar_extractor_do_write_entry: %s\n", extractor->error->message);
+ g_error_free (extractor->error);
+ extractor->error = NULL;
}
g_object_unref (info);
}
static void
-autoar_extract_class_init (AutoarExtractClass *klass)
+autoar_extractor_class_init (AutoarExtractorClass *klass)
{
GObjectClass *object_class;
GType type;
@@ -1249,10 +1257,10 @@ autoar_extract_class_init (AutoarExtractClass *klass)
object_class = G_OBJECT_CLASS (klass);
type = G_TYPE_FROM_CLASS (klass);
- object_class->get_property = autoar_extract_get_property;
- object_class->set_property = autoar_extract_set_property;
- object_class->dispose = autoar_extract_dispose;
- object_class->finalize = autoar_extract_finalize;
+ object_class->get_property = autoar_extractor_get_property;
+ object_class->set_property = autoar_extractor_set_property;
+ object_class->dispose = autoar_extractor_dispose;
+ object_class->finalize = autoar_extractor_finalize;
g_object_class_install_property (object_class, PROP_SOURCE_FILE,
g_param_spec_object ("source-file",
@@ -1333,14 +1341,14 @@ autoar_extract_class_init (AutoarExtractClass *klass)
G_PARAM_STATIC_STRINGS));
/**
- * AutoarExtract::scanned:
- * @arextract: the #AutoarExtract
+ * AutoarExtractor::scanned:
+ * @extractor: the #AutoarExtractor
* @files: the number of files will be extracted from the source archive
*
- * This signal is emitted when #AutoarExtract finish scanning filename entries
+ * This signal is emitted when #AutoarExtractor finish scanning filename entries
* in the source archive.
**/
- autoar_extract_signals[SCANNED] =
+ autoar_extractor_signals[SCANNED] =
g_signal_new ("scanned",
type,
G_SIGNAL_RUN_LAST,
@@ -1351,8 +1359,8 @@ autoar_extract_class_init (AutoarExtractClass *klass)
G_TYPE_UINT);
/**
- * AutoarExtract::decide-destination:
- * @arextract: the #AutoarExtract
+ * AutoarExtractor::decide-destination:
+ * @extractor: the #AutoarExtractor
* @destination: the location where files will be extracted
* @files: the list of files to be extracted. All have @destination as their
common prefix
@@ -1364,7 +1372,7 @@ autoar_extract_class_init (AutoarExtractClass *klass)
* determined. It is useful for solving name conflicts or for setting a new
* destination, based on the contents of the archive.
**/
- autoar_extract_signals[DECIDE_DESTINATION] =
+ autoar_extractor_signals[DECIDE_DESTINATION] =
g_signal_new ("decide-destination",
type,
G_SIGNAL_RUN_LAST,
@@ -1376,14 +1384,14 @@ autoar_extract_class_init (AutoarExtractClass *klass)
G_TYPE_POINTER);
/**
- * AutoarExtract::progress:
- * @arextract: the #AutoarExtract
+ * AutoarExtractor::progress:
+ * @extractor: the #AutoarExtractor
* @completed_size: bytes has been written to disk
* @completed_files: number of files have been written to disk
*
* This signal is used to report progress of creating archives.
**/
- autoar_extract_signals[PROGRESS] =
+ autoar_extractor_signals[PROGRESS] =
g_signal_new ("progress",
type,
G_SIGNAL_RUN_LAST,
@@ -1395,17 +1403,17 @@ autoar_extract_class_init (AutoarExtractClass *klass)
G_TYPE_UINT);
/**
- * AutoarExtract::conflict:
- * @arextract: the #AutoarExtract
+ * AutoarExtractor::conflict:
+ * @extractor: the #AutoarExtractor
* @file: the file that caused a conflict
* @new_file: an address to store the new destination for a conflict file
*
- * Returns: the action to be performed by #AutoarExtract
+ * Returns: the action to be performed by #AutoarExtractor
*
* This signal is used to report and offer the possibility to solve name
* conflicts when extracting files.
**/
- autoar_extract_signals[CONFLICT] =
+ autoar_extractor_signals[CONFLICT] =
g_signal_new ("conflict",
type,
G_SIGNAL_RUN_LAST,
@@ -1417,13 +1425,13 @@ autoar_extract_class_init (AutoarExtractClass *klass)
G_TYPE_POINTER);
/**
- * AutoarExtract::cancelled:
- * @arextract: the #AutoarExtract
+ * AutoarExtractor::cancelled:
+ * @extractor: the #AutoarExtractor
*
* This signal is emitted after archive extracting job is cancelled by the
* #GCancellable.
**/
- autoar_extract_signals[CANCELLED] =
+ autoar_extractor_signals[CANCELLED] =
g_signal_new ("cancelled",
type,
G_SIGNAL_RUN_LAST,
@@ -1433,13 +1441,13 @@ autoar_extract_class_init (AutoarExtractClass *klass)
0);
/**
- * AutoarExtract::completed:
- * @arextract: the #AutoarExtract
+ * AutoarExtractor::completed:
+ * @extractor: the #AutoarExtractor
*
* This signal is emitted after the archive extracting job is successfully
* completed.
**/
- autoar_extract_signals[COMPLETED] =
+ autoar_extractor_signals[COMPLETED] =
g_signal_new ("completed",
type,
G_SIGNAL_RUN_LAST,
@@ -1449,17 +1457,17 @@ autoar_extract_class_init (AutoarExtractClass *klass)
0);
/**
- * AutoarExtract::error:
- * @arextract: the #AutoarExtract
+ * AutoarExtractor::error:
+ * @extractor: the #AutoarExtractor
* @error: the #GError
*
* This signal is emitted when error occurs and all jobs should be terminated.
- * Possible error domains are %AUTOAR_EXTRACT_ERROR, %G_IO_ERROR, and
- * %AUTOAR_LIBARCHIVE_ERROR, which represent error occurs in #AutoarExtract,
- * GIO, and libarchive, respectively. The #GError is owned by #AutoarExtract
+ * Possible error domains are %AUTOAR_EXTRACTOR_ERROR, %G_IO_ERROR, and
+ * %AUTOAR_LIBARCHIVE_ERROR, which represent error occurs in #AutoarExtractor,
+ * GIO, and libarchive, respectively. The #GError is owned by #AutoarExtractor
* and should not be freed.
**/
- autoar_extract_signals[AR_ERROR] =
+ autoar_extractor_signals[AR_ERROR] =
g_signal_new ("error",
type,
G_SIGNAL_RUN_LAST,
@@ -1471,73 +1479,73 @@ autoar_extract_class_init (AutoarExtractClass *klass)
}
static void
-autoar_extract_init (AutoarExtract *arextract)
+autoar_extractor_init (AutoarExtractor *extractor)
{
- arextract->cancellable = NULL;
+ extractor->cancellable = NULL;
- arextract->size = 0;
- arextract->completed_size = 0;
+ extractor->size = 0;
+ extractor->completed_size = 0;
- arextract->files_list = NULL;
+ extractor->files_list = NULL;
- arextract->files = 0;
- arextract->completed_files = 0;
+ extractor->files = 0;
+ extractor->completed_files = 0;
- arextract->notify_last = 0;
+ extractor->notify_last = 0;
- arextract->istream = NULL;
- arextract->buffer_size = BUFFER_SIZE;
- arextract->buffer = g_new (char, arextract->buffer_size);
- arextract->error = NULL;
+ extractor->istream = NULL;
+ extractor->buffer_size = BUFFER_SIZE;
+ extractor->buffer = g_new (char, extractor->buffer_size);
+ extractor->error = NULL;
- arextract->userhash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- arextract->grouphash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- arextract->extracted_dir_list = g_array_new (FALSE, FALSE, sizeof (GFileAndInfo));
- g_array_set_clear_func (arextract->extracted_dir_list, g_file_and_info_free);
- arextract->destination_dir = NULL;
- arextract->new_prefix = NULL;
+ extractor->userhash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ extractor->grouphash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ extractor->extracted_dir_list = g_array_new (FALSE, FALSE, sizeof (GFileAndInfo));
+ g_array_set_clear_func (extractor->extracted_dir_list, g_file_and_info_free);
+ extractor->destination_dir = NULL;
+ extractor->new_prefix = NULL;
- arextract->suggested_destname = NULL;
+ extractor->suggested_destname = NULL;
- arextract->in_thread = FALSE;
- arextract->use_raw_format = FALSE;
+ extractor->in_thread = FALSE;
+ extractor->use_raw_format = FALSE;
}
/**
- * autoar_extract_new:
+ * autoar_extractor_new:
* @source_file: source archive
* @output_file: output directory of extracted file or directory, or the
* file name of the extracted file or directory itself if you set
- * #AutoarExtract:output-is-dest on the returned object
+ * #AutoarExtractor:output-is-dest on the returned object
*
- * Create a new #AutoarExtract object.
+ * Create a new #AutoarExtractor object.
*
- * Returns: (transfer full): a new #AutoarExtract object
+ * Returns: (transfer full): a new #AutoarExtractor object
**/
-AutoarExtract*
-autoar_extract_new (GFile *source_file,
- GFile *output_file)
+AutoarExtractor*
+autoar_extractor_new (GFile *source_file,
+ GFile *output_file)
{
- AutoarExtract *arextract;
+ AutoarExtractor *extractor;
g_return_val_if_fail (source_file != NULL, NULL);
g_return_val_if_fail (output_file != NULL, NULL);
- arextract = g_object_new (AUTOAR_TYPE_EXTRACT,
+ extractor = g_object_new (AUTOAR_TYPE_EXTRACTOR,
"source-file", source_file,
"output-file", output_file,
NULL);
- arextract->source_basename =
- g_file_get_basename (arextract->source_file);
- arextract->suggested_destname =
- autoar_common_get_basename_remove_extension (arextract->source_basename);
+ extractor->source_basename =
+ g_file_get_basename (extractor->source_file);
+ extractor->suggested_destname =
+ autoar_common_get_basename_remove_extension (extractor->source_basename);
- return arextract;
+ return extractor;
}
static void
-autoar_extract_step_scan_toplevel (AutoarExtract *arextract)
+autoar_extractor_step_scan_toplevel (AutoarExtractor *extractor)
{
/* Step 0: Scan all file names in the archive
* We have to check whether the archive contains a top-level directory
@@ -1549,58 +1557,67 @@ autoar_extract_step_scan_toplevel (AutoarExtract *arextract)
int r;
- g_debug ("autoar_extract_step_scan_toplevel: called");
+ g_debug ("autoar_extractor_step_scan_toplevel: called");
- r = libarchive_create_read_object (FALSE, arextract, &a);
+ r = libarchive_create_read_object (FALSE, extractor, &a);
if (r != ARCHIVE_OK) {
archive_read_free (a);
- r = libarchive_create_read_object (TRUE, arextract, &a);
+ r = libarchive_create_read_object (TRUE, extractor, &a);
if (r != ARCHIVE_OK) {
- if (arextract->error == NULL)
- arextract->error = autoar_common_g_error_new_a (a, arextract->source_basename);
+ if (extractor->error == NULL)
+ extractor->error = autoar_common_g_error_new_a (a, extractor->source_basename);
return;
} else if (archive_filter_count (a) <= 1){
/* If we only use raw format and filter count is one, libarchive will
* not do anything except for just copying the source file. We do not
* want this thing to happen because it does unnecesssary copying. */
- if (arextract->error == NULL)
- arextract->error = g_error_new (AUTOAR_EXTRACT_ERROR, NOT_AN_ARCHIVE_ERRNO,
- "\'%s\': %s", arextract->source_basename, "not an archive");
+ if (extractor->error == NULL)
+ extractor->error = g_error_new (AUTOAR_EXTRACTOR_ERROR,
+ NOT_AN_ARCHIVE_ERRNO,
+ "\'%s\': %s",
+ extractor->source_basename,
+ "not an archive");
return;
}
- arextract->use_raw_format = TRUE;
+ extractor->use_raw_format = TRUE;
}
while ((r = archive_read_next_header (a, &entry)) == ARCHIVE_OK) {
const char *pathname;
- if (g_cancellable_is_cancelled (arextract->cancellable)) {
+ if (g_cancellable_is_cancelled (extractor->cancellable)) {
archive_read_free (a);
return;
}
pathname = archive_entry_pathname (entry);
- g_debug ("autoar_extract_step_scan_toplevel: %d: pathname = %s", arextract->files, pathname);
-
- arextract->files_list = g_list_prepend (arextract->files_list,
- g_file_get_child (arextract->output_file, pathname));
- arextract->files++;
- arextract->size += archive_entry_size (entry);
+ g_debug ("autoar_extractor_step_scan_toplevel: %d: pathname = %s",
+ extractor->files, pathname);
+
+ extractor->files_list =
+ g_list_prepend (extractor->files_list,
+ g_file_get_child (extractor->output_file, pathname));
+ extractor->files++;
+ extractor->size += archive_entry_size (entry);
archive_read_data_skip (a);
}
- if (arextract->files_list == NULL) {
- if (arextract->error == NULL) {
- arextract->error = g_error_new (AUTOAR_EXTRACT_ERROR, EMPTY_ARCHIVE_ERRNO,
- "\'%s\': %s", arextract->source_basename, "empty archive");
+ if (extractor->files_list == NULL) {
+ if (extractor->error == NULL) {
+ extractor->error = g_error_new (AUTOAR_EXTRACTOR_ERROR,
+ EMPTY_ARCHIVE_ERRNO,
+ "\'%s\': %s",
+ extractor->source_basename,
+ "empty archive");
}
archive_read_free (a);
return;
}
if (r != ARCHIVE_EOF) {
- if (arextract->error == NULL) {
- arextract->error = autoar_common_g_error_new_a (a, arextract->source_basename);
+ if (extractor->error == NULL) {
+ extractor->error =
+ autoar_common_g_error_new_a (a, extractor->source_basename);
}
archive_read_free (a);
return;
@@ -1608,40 +1625,43 @@ autoar_extract_step_scan_toplevel (AutoarExtract *arextract)
/* If we are unable to determine the total size, set it to a positive
* number to prevent strange percentage. */
- if (arextract->size <= 0)
- arextract->size = G_MAXUINT64;
+ if (extractor->size <= 0)
+ extractor->size = G_MAXUINT64;
archive_read_free (a);
- g_debug ("autoar_extract_step_scan_toplevel: files = %d", arextract->files);
+ g_debug ("autoar_extractor_step_scan_toplevel: files = %d", extractor->files);
- arextract->files_list = g_list_reverse (arextract->files_list);
+ extractor->files_list = g_list_reverse (extractor->files_list);
- arextract->prefix = autoar_extract_get_common_prefix (arextract->files_list, arextract->output_file);
+ extractor->prefix =
+ autoar_extractor_get_common_prefix (extractor->files_list,
+ extractor->output_file);
- if (arextract->prefix != NULL) {
+ if (extractor->prefix != NULL) {
g_autofree char *path_prefix;
- path_prefix = g_file_get_path (arextract->prefix);
- g_debug ("autoar_extract_step_scan_toplevel: pathname_prefix = %s", path_prefix);
+ path_prefix = g_file_get_path (extractor->prefix);
+ g_debug ("autoar_extractor_step_scan_toplevel: pathname_prefix = %s",
+ path_prefix);
}
- autoar_extract_signal_scanned (arextract);
+ autoar_extractor_signal_scanned (extractor);
}
static void
-autoar_extract_step_set_dest (AutoarExtract *arextract)
+autoar_extractor_step_set_dest (AutoarExtractor *extractor)
{
/* Step 1: Set destination based on client preferences or archive contents */
- g_debug ("autoar_extract_step_set_dest: called");
+ g_debug ("autoar_extractor_step_set_dest: called");
- if (arextract->output_is_dest) {
- arextract->destination_dir = g_object_ref (arextract->output_file);
+ if (extractor->output_is_dest) {
+ extractor->destination_dir = g_object_ref (extractor->output_file);
return;
}
- if (arextract->prefix != NULL) {
+ if (extractor->prefix != NULL) {
/* We must check if the archive and the prefix have the same name (without
* the extension). If they do, then the destination should be the output
* directory itself.
@@ -1649,26 +1669,26 @@ autoar_extract_step_set_dest (AutoarExtract *arextract)
g_autofree char *prefix_name;
g_autofree char *prefix_name_no_ext;
- prefix_name = g_file_get_basename (arextract->prefix);
+ prefix_name = g_file_get_basename (extractor->prefix);
prefix_name_no_ext = autoar_common_get_basename_remove_extension (prefix_name);
- if (g_strcmp0 (prefix_name_no_ext, arextract->suggested_destname) == 0) {
- arextract->destination_dir = g_object_ref (arextract->output_file);
+ if (g_strcmp0 (prefix_name_no_ext, extractor->suggested_destname) == 0) {
+ extractor->destination_dir = g_object_ref (extractor->output_file);
} else {
- g_clear_object (&arextract->prefix);
+ g_clear_object (&extractor->prefix);
}
}
/* If none of the above situations apply, the top level directory gets the
- * name suggested when creating the AutoarExtract object
+ * name suggested when creating the AutoarExtractor object
*/
- if (arextract->destination_dir == NULL) {
- arextract->destination_dir = g_file_get_child (arextract->output_file,
- arextract->suggested_destname);
+ if (extractor->destination_dir == NULL) {
+ extractor->destination_dir = g_file_get_child (extractor->output_file,
+ extractor->suggested_destname);
}
}
static void
-autoar_extract_step_decide_dest (AutoarExtract *arextract)
+autoar_extractor_step_decide_dest (AutoarExtractor *extractor)
{
/* Step 2: Decide destination */
@@ -1676,12 +1696,12 @@ autoar_extract_step_decide_dest (AutoarExtract *arextract)
GList *l;
GFile *new_destination = NULL;
- for (l = arextract->files_list; l != NULL; l = l->next) {
+ for (l = extractor->files_list; l != NULL; l = l->next) {
char *relative_path;
GFile *file;
- relative_path = g_file_get_relative_path (arextract->output_file, l->data);
- file = g_file_resolve_relative_path (arextract->destination_dir,
+ relative_path = g_file_get_relative_path (extractor->output_file, l->data);
+ file = g_file_resolve_relative_path (extractor->destination_dir,
relative_path);
files = g_list_prepend (files, file);
@@ -1694,47 +1714,48 @@ autoar_extract_step_decide_dest (AutoarExtract *arextract)
* and the client has the opportunity to change it. Also, the old prefix is
* needed in order to replace it with the new one
*/
- if (arextract->prefix != NULL) {
- autoar_extract_signal_decide_destination (arextract,
- arextract->prefix,
- files,
- &new_destination);
+ if (extractor->prefix != NULL) {
+ autoar_extractor_signal_decide_destination (extractor,
+ extractor->prefix,
+ files,
+ &new_destination);
- arextract->new_prefix = new_destination;
+ extractor->new_prefix = new_destination;
} else {
- autoar_extract_signal_decide_destination (arextract,
- arextract->destination_dir,
- files,
- &new_destination);
+ autoar_extractor_signal_decide_destination (extractor,
+ extractor->destination_dir,
+ files,
+ &new_destination);
if (new_destination) {
- g_object_unref (arextract->destination_dir);
- arextract->destination_dir = new_destination;
+ g_object_unref (extractor->destination_dir);
+ extractor->destination_dir = new_destination;
}
}
{
g_autofree char *destination_name;
- destination_name = g_file_get_path (arextract->new_prefix != NULL ?
- arextract->new_prefix :
- arextract->destination_dir);
- g_debug ("autoar_extract_step_decide_dest: destination %s", destination_name);
+ destination_name = g_file_get_path (extractor->new_prefix != NULL ?
+ extractor->new_prefix :
+ extractor->destination_dir);
+ g_debug ("autoar_extractor_step_decide_dest: destination %s", destination_name);
}
- g_file_make_directory_with_parents (arextract->destination_dir, arextract->cancellable,
- &(arextract->error));
+ g_file_make_directory_with_parents (extractor->destination_dir,
+ extractor->cancellable,
+ &(extractor->error));
- if (g_error_matches (arextract->error, G_IO_ERROR, G_IO_ERROR_EXISTS)) {
+ if (g_error_matches (extractor->error, G_IO_ERROR, G_IO_ERROR_EXISTS)) {
GFileType file_type;
- file_type = g_file_query_file_type (arextract->destination_dir,
+ file_type = g_file_query_file_type (extractor->destination_dir,
G_FILE_QUERY_INFO_NONE,
NULL);
if (file_type == G_FILE_TYPE_DIRECTORY) {
- g_debug ("autoar_extract_step_decide_dest: destination directory exists");
- g_clear_error (&arextract->error);
+ g_debug ("autoar_extractor_step_decide_dest: destination directory exists");
+ g_clear_error (&extractor->error);
}
}
@@ -1742,7 +1763,7 @@ autoar_extract_step_decide_dest (AutoarExtract *arextract)
}
static void
-autoar_extract_step_extract (AutoarExtract *arextract) {
+autoar_extractor_step_extract (AutoarExtractor *extractor) {
/* Step 3: Extract files
* We have to re-open the archive to extract files
*/
@@ -1752,12 +1773,13 @@ autoar_extract_step_extract (AutoarExtract *arextract) {
int r;
- g_debug ("autoar_extract_step_extract: called");
+ g_debug ("autoar_extractor_step_extract: called");
- r = libarchive_create_read_object (arextract->use_raw_format, arextract, &a);
+ r = libarchive_create_read_object (extractor->use_raw_format, extractor, &a);
if (r != ARCHIVE_OK) {
- if (arextract->error == NULL) {
- arextract->error = autoar_common_g_error_new_a (a, arextract->source_basename);
+ if (extractor->error == NULL) {
+ extractor->error =
+ autoar_common_g_error_new_a (a, extractor->source_basename);
}
archive_read_free (a);
return;
@@ -1769,7 +1791,7 @@ autoar_extract_step_extract (AutoarExtract *arextract) {
g_autoptr (GFile) extracted_filename = NULL;
g_autoptr (GFile) hardlink_filename = NULL;
- if (g_cancellable_is_cancelled (arextract->cancellable)) {
+ if (g_cancellable_is_cancelled (extractor->cancellable)) {
archive_read_free (a);
return;
}
@@ -1778,22 +1800,22 @@ autoar_extract_step_extract (AutoarExtract *arextract) {
hardlink = archive_entry_hardlink (entry);
extracted_filename =
- autoar_extract_do_sanitize_pathname (arextract, pathname);
+ autoar_extractor_do_sanitize_pathname (extractor, pathname);
if (hardlink != NULL) {
hardlink_filename =
- autoar_extract_do_sanitize_pathname (arextract, hardlink);
+ autoar_extractor_do_sanitize_pathname (extractor, hardlink);
}
/* Attempt to solve any name conflict before doing any operations */
- if (autoar_extract_check_file_conflict (extracted_filename,
- archive_entry_filetype (entry))) {
+ if (autoar_extractor_check_file_conflict (extracted_filename,
+ archive_entry_filetype (entry))) {
GFile *new_extracted_filename = NULL;
AutoarConflictAction action;
- action = autoar_extract_signal_conflict (arextract,
- extracted_filename,
- &new_extracted_filename);
+ action = autoar_extractor_signal_conflict (extractor,
+ extracted_filename,
+ &new_extracted_filename);
switch (action) {
case AUTOAR_CONFLICT_OVERWRITE:
@@ -1816,21 +1838,22 @@ autoar_extract_step_extract (AutoarExtract *arextract) {
}
}
- autoar_extract_do_write_entry (arextract, a, entry,
- extracted_filename, hardlink_filename);
+ autoar_extractor_do_write_entry (extractor, a, entry,
+ extracted_filename, hardlink_filename);
- if (arextract->error != NULL) {
+ if (extractor->error != NULL) {
archive_read_free (a);
return;
}
- arextract->completed_files++;
- autoar_extract_signal_progress (arextract);
+ extractor->completed_files++;
+ autoar_extractor_signal_progress (extractor);
}
if (r != ARCHIVE_EOF) {
- if (arextract->error == NULL) {
- arextract->error = autoar_common_g_error_new_a (a, arextract->source_basename);
+ if (extractor->error == NULL) {
+ extractor->error =
+ autoar_common_g_error_new_a (a, extractor->source_basename);
}
archive_read_free (a);
return;
@@ -1840,7 +1863,7 @@ autoar_extract_step_extract (AutoarExtract *arextract) {
}
static void
-autoar_extract_step_apply_dir_fileinfo (AutoarExtract *arextract) {
+autoar_extractor_step_apply_dir_fileinfo (AutoarExtractor *extractor) {
/* Step 4: Re-apply file info to all directories
* It is required because modification times may be updated during the
* writing of files in the directory.
@@ -1848,143 +1871,143 @@ autoar_extract_step_apply_dir_fileinfo (AutoarExtract *arextract) {
int i;
- g_debug ("autoar_extract_step_apply_dir_fileinfo: called");
+ g_debug ("autoar_extractor_step_apply_dir_fileinfo: called");
- for (i = 0; i < arextract->extracted_dir_list->len; i++) {
- GFile *file = g_array_index (arextract->extracted_dir_list, GFileAndInfo, i).file;
- GFileInfo *info = g_array_index (arextract->extracted_dir_list, GFileAndInfo, i).info;
+ for (i = 0; i < extractor->extracted_dir_list->len; i++) {
+ GFile *file = g_array_index (extractor->extracted_dir_list, GFileAndInfo, i).file;
+ GFileInfo *info = g_array_index (extractor->extracted_dir_list, GFileAndInfo, i).info;
g_file_set_attributes_from_info (file, info,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
- arextract->cancellable, NULL);
- if (g_cancellable_is_cancelled (arextract->cancellable)) {
+ extractor->cancellable, NULL);
+ if (g_cancellable_is_cancelled (extractor->cancellable)) {
return;
}
}
}
static void
-autoar_extract_step_cleanup (AutoarExtract *arextract) {
+autoar_extractor_step_cleanup (AutoarExtractor *extractor) {
/* Step 5: Force progress to be 100% and remove the source archive file
* If the extraction is completed successfully, remove the source file.
* Errors are not fatal because we have completed our work.
*/
- g_debug ("autoar_extract_step_cleanup: called");
+ g_debug ("autoar_extractor_step_cleanup: called");
- arextract->completed_size = arextract->size;
- arextract->completed_files = arextract->files;
- arextract->notify_last = 0;
- autoar_extract_signal_progress (arextract);
- g_debug ("autoar_extract_step_cleanup: Update progress");
+ extractor->completed_size = extractor->size;
+ extractor->completed_files = extractor->files;
+ extractor->notify_last = 0;
+ autoar_extractor_signal_progress (extractor);
+ g_debug ("autoar_extractor_step_cleanup: Update progress");
- if (arextract->delete_if_succeed) {
- g_debug ("autoar_extract_step_cleanup: Delete");
- g_file_delete (arextract->source_file, arextract->cancellable, NULL);
+ if (extractor->delete_if_succeed) {
+ g_debug ("autoar_extractor_step_cleanup: Delete");
+ g_file_delete (extractor->source_file, extractor->cancellable, NULL);
}
}
static void
-autoar_extract_run (AutoarExtract *arextract)
+autoar_extractor_run (AutoarExtractor *extractor)
{
/* Numbers of steps.
* The array size must be modified if more steps are added. */
- void (*steps[7])(AutoarExtract*);
+ void (*steps[7])(AutoarExtractor*);
int i;
- g_return_if_fail (AUTOAR_IS_EXTRACT (arextract));
+ g_return_if_fail (AUTOAR_IS_EXTRACTOR (extractor));
- g_return_if_fail (arextract->source_file != NULL);
- g_return_if_fail (arextract->output_file != NULL);
+ g_return_if_fail (extractor->source_file != NULL);
+ g_return_if_fail (extractor->output_file != NULL);
- if (g_cancellable_is_cancelled (arextract->cancellable)) {
- autoar_extract_signal_cancelled (arextract);
+ if (g_cancellable_is_cancelled (extractor->cancellable)) {
+ autoar_extractor_signal_cancelled (extractor);
return;
}
i = 0;
- steps[i++] = autoar_extract_step_scan_toplevel;
- steps[i++] = autoar_extract_step_set_dest;
- steps[i++] = autoar_extract_step_decide_dest;
- steps[i++] = autoar_extract_step_extract;
- steps[i++] = autoar_extract_step_apply_dir_fileinfo;
- steps[i++] = autoar_extract_step_cleanup;
+ steps[i++] = autoar_extractor_step_scan_toplevel;
+ steps[i++] = autoar_extractor_step_set_dest;
+ steps[i++] = autoar_extractor_step_decide_dest;
+ steps[i++] = autoar_extractor_step_extract;
+ steps[i++] = autoar_extractor_step_apply_dir_fileinfo;
+ steps[i++] = autoar_extractor_step_cleanup;
steps[i++] = NULL;
for (i = 0; steps[i] != NULL; i++) {
- g_debug ("autoar_extract_run: Step %d Begin", i);
- (*steps[i])(arextract);
- g_debug ("autoar_extract_run: Step %d End", i);
- if (arextract->error != NULL) {
- autoar_extract_signal_error (arextract);
+ g_debug ("autoar_extractor_run: Step %d Begin", i);
+ (*steps[i])(extractor);
+ g_debug ("autoar_extractor_run: Step %d End", i);
+ if (extractor->error != NULL) {
+ autoar_extractor_signal_error (extractor);
return;
}
- if (g_cancellable_is_cancelled (arextract->cancellable)) {
- autoar_extract_signal_cancelled (arextract);
+ if (g_cancellable_is_cancelled (extractor->cancellable)) {
+ autoar_extractor_signal_cancelled (extractor);
return;
}
}
- autoar_extract_signal_completed (arextract);
+ autoar_extractor_signal_completed (extractor);
}
/**
- * autoar_extract_start:
- * @arextract: an #AutoarExtract object
+ * autoar_extractor_start:
+ * @extractor: an #AutoarExtractor object
* @cancellable: optional #GCancellable object, or %NULL to ignore
*
* Runs the archive extracting work. All callbacks will be called in the same
* thread as the caller of this functions.
**/
void
-autoar_extract_start (AutoarExtract *arextract,
- GCancellable *cancellable)
+autoar_extractor_start (AutoarExtractor *extractor,
+ GCancellable *cancellable)
{
if (cancellable != NULL)
g_object_ref (cancellable);
- arextract->cancellable = cancellable;
- arextract->in_thread = FALSE;
- autoar_extract_run (arextract);
+ extractor->cancellable = cancellable;
+ extractor->in_thread = FALSE;
+ autoar_extractor_run (extractor);
}
static void
-autoar_extract_start_async_thread (GTask *task,
- gpointer source_object,
- gpointer task_data,
- GCancellable *cancellable)
+autoar_extractor_start_async_thread (GTask *task,
+ gpointer source_object,
+ gpointer task_data,
+ GCancellable *cancellable)
{
- AutoarExtract *arextract = source_object;
- autoar_extract_run (arextract);
+ AutoarExtractor *extractor = source_object;
+ autoar_extractor_run (extractor);
g_task_return_pointer (task, NULL, g_free);
- g_object_unref (arextract);
+ g_object_unref (extractor);
g_object_unref (task);
}
/**
- * autoar_extract_start_async:
- * @arextract: an #AutoarExtract object
+ * autoar_extractor_start_async:
+ * @extractor: an #AutoarExtractor object
* @cancellable: optional #GCancellable object, or %NULL to ignore
*
* Asynchronously runs the archive extracting work. You should connect to
- * #AutoarExtract::cancelled, #AutoarExtract::error, and
- * #AutoarExtract::completed signal to get notification when the work is
+ * #AutoarExtractor::cancelled, #AutoarExtractor::error, and
+ * #AutoarExtractor::completed signal to get notification when the work is
* terminated. All callbacks will be called in the main thread, so you can
* safely manipulate GTK+ widgets in the callbacks.
**/
void
-autoar_extract_start_async (AutoarExtract *arextract,
- GCancellable *cancellable)
+autoar_extractor_start_async (AutoarExtractor *extractor,
+ GCancellable *cancellable)
{
GTask *task;
- g_object_ref (arextract);
+ g_object_ref (extractor);
if (cancellable != NULL)
g_object_ref (cancellable);
- arextract->cancellable = cancellable;
- arextract->in_thread = TRUE;
+ extractor->cancellable = cancellable;
+ extractor->in_thread = TRUE;
- task = g_task_new (arextract, NULL, NULL, NULL);
+ task = g_task_new (extractor, NULL, NULL, NULL);
g_task_set_task_data (task, NULL, NULL);
- g_task_run_in_thread (task, autoar_extract_start_async_thread);
+ g_task_run_in_thread (task, autoar_extractor_start_async_thread);
}
diff --git a/gnome-autoar/autoar-extractor.h b/gnome-autoar/autoar-extractor.h
new file mode 100644
index 0000000..b67a425
--- /dev/null
+++ b/gnome-autoar/autoar-extractor.h
@@ -0,0 +1,86 @@
+/* vim: set sw=2 ts=2 sts=2 et: */
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * autoar-extractor.h
+ * Automatically extract archives in some GNOME programs
+ *
+ * Copyright (C) 2013 Ting-Wei Lan
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef AUTOAR_EXTRACTOR_H
+#define AUTOAR_EXTRACTOR_H
+
+#include <glib-object.h>
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+#define AUTOAR_TYPE_EXTRACTOR autoar_extractor_get_type ()
+
+G_DECLARE_FINAL_TYPE (AutoarExtractor, autoar_extractor, AUTOAR, EXTRACTOR, GObject)
+
+/**
+ * AUTOAR_EXTRACT_ERROR:
+ *
+ * Error domain for #AutoarExtractor. Not all error occurs in #AutoarExtractor uses
+ * this domain. It is only used for error occurs in #AutoarExtractor itself.
+ * See #AutoarExtractor::error signal for more information.
+ **/
+#define AUTOAR_EXTRACTOR_ERROR autoar_extractor_quark()
+
+GQuark autoar_extractor_quark (void);
+
+GType autoar_extractor_get_type (void) G_GNUC_CONST;
+
+AutoarExtractor *autoar_extractor_new (GFile *source_file,
+ GFile *output_file);
+
+void autoar_extractor_start (AutoarExtractor *extractor,
+ GCancellable *cancellable);
+void autoar_extractor_start_async (AutoarExtractor *extractor,
+ GCancellable *cancellable);
+
+char *autoar_extractor_get_source (AutoarExtractor *extractor);
+GFile *autoar_extractor_get_source_file (AutoarExtractor *extractor);
+char *autoar_extractor_get_output (AutoarExtractor *extractor);
+GFile *autoar_extractor_get_output_file (AutoarExtractor *extractor);
+guint64 autoar_extractor_get_size (AutoarExtractor *extractor);
+guint64 autoar_extractor_get_completed_size (AutoarExtractor *extractor);
+guint autoar_extractor_get_files (AutoarExtractor *extractor);
+guint autoar_extractor_get_completed_files (AutoarExtractor *extractor);
+gboolean autoar_extractor_get_output_is_dest (AutoarExtractor *extractor);
+gboolean autoar_extractor_get_delete_if_succeed (AutoarExtractor *extractor);
+gint64 autoar_extractor_get_notify_interval (AutoarExtractor *extractor);
+
+void autoar_extractor_set_output_is_dest (AutoarExtractor *extractor,
+ gboolean output_is_dest);
+void autoar_extractor_set_delete_if_succeed (AutoarExtractor *extractor,
+ gboolean delete_if_succeed);
+void autoar_extractor_set_notify_interval (AutoarExtractor *extractor,
+ gint64 notify_interval);
+
+typedef enum {
+ AUTOAR_CONFLICT_OVERWRITE = 0,
+ AUTOAR_CONFLICT_CHANGE_DESTINATION,
+ AUTOAR_CONFLICT_SKIP
+} AutoarConflictAction;
+
+G_END_DECLS
+
+#endif /* AUTOAR_EXTRACTOR_H */
diff --git a/gnome-autoar/autoar.h b/gnome-autoar/autoar.h
index 3ccc8a9..163de1c 100644
--- a/gnome-autoar/autoar.h
+++ b/gnome-autoar/autoar.h
@@ -25,7 +25,7 @@
#include <gnome-autoar/autoar-create.h>
#include <gnome-autoar/autoar-format-filter.h>
-#include <gnome-autoar/autoar-extract.h>
+#include <gnome-autoar/autoar-extractor.h>
#include <gnome-autoar/autoar-misc.h>
#include <gnome-autoar/autoar-pref.h>
diff --git a/tests/test-extract-unit.c b/tests/test-extract-unit.c
index 48a93b4..a2ff8f2 100644
--- a/tests/test-extract-unit.c
+++ b/tests/test-extract-unit.c
@@ -147,7 +147,7 @@ extract_test_free (ExtractTest *extract_test)
}
static void
-scanned_handler (AutoarExtract *arextract,
+scanned_handler (AutoarExtractor *extractor,
guint files,
gpointer user_data)
{
@@ -157,7 +157,7 @@ scanned_handler (AutoarExtract *arextract,
}
static GFile*
-decide_destination_handler (AutoarExtract *arextract,
+decide_destination_handler (AutoarExtractor *extractor,
GFile *dest,
GList *files,
gpointer user_data)
@@ -174,7 +174,7 @@ decide_destination_handler (AutoarExtract *arextract,
}
static void
-progress_handler (AutoarExtract *arextract,
+progress_handler (AutoarExtractor *extractor,
guint64 completed_size,
guint completed_files,
gpointer user_data)
@@ -186,7 +186,7 @@ progress_handler (AutoarExtract *arextract,
}
static AutoarConflictAction
-conflict_handler (AutoarExtract *arextract,
+conflict_handler (AutoarExtractor *extractor,
GFile *file,
GFile **new_file,
gpointer user_data)
@@ -222,7 +222,7 @@ conflict_handler (AutoarExtract *arextract,
}
static void
-error_handler (AutoarExtract *arextract,
+error_handler (AutoarExtractor *extractor,
GError *error,
gpointer user_data)
{
@@ -232,7 +232,7 @@ error_handler (AutoarExtract *arextract,
}
static void
-completed_handler (AutoarExtract *arextract,
+completed_handler (AutoarExtractor *extractor,
gpointer user_data)
{
ExtractTestData *data = user_data;
@@ -241,7 +241,7 @@ completed_handler (AutoarExtract *arextract,
}
static void
-cancelled_handler (AutoarExtract *arextract,
+cancelled_handler (AutoarExtractor *extractor,
gpointer user_data)
{
ExtractTestData *data = user_data;
@@ -250,7 +250,7 @@ cancelled_handler (AutoarExtract *arextract,
}
static ExtractTestData*
-extract_test_data_new_for_extract (AutoarExtract *arextract)
+extract_test_data_new_for_extract (AutoarExtractor *extractor)
{
ExtractTestData *data;
@@ -258,19 +258,19 @@ extract_test_data_new_for_extract (AutoarExtract *arextract)
data->cancellable = g_cancellable_new ();
- g_signal_connect (arextract, "scanned",
+ g_signal_connect (extractor, "scanned",
G_CALLBACK (scanned_handler), data);
- g_signal_connect (arextract, "decide-destination",
+ g_signal_connect (extractor, "decide-destination",
G_CALLBACK (decide_destination_handler), data);
- g_signal_connect (arextract, "progress",
+ g_signal_connect (extractor, "progress",
G_CALLBACK (progress_handler), data);
- g_signal_connect (arextract, "conflict",
+ g_signal_connect (extractor, "conflict",
G_CALLBACK (conflict_handler), data);
- g_signal_connect (arextract, "completed",
+ g_signal_connect (extractor, "completed",
G_CALLBACK (completed_handler), data);
- g_signal_connect (arextract, "error",
+ g_signal_connect (extractor, "error",
G_CALLBACK (error_handler), data);
- g_signal_connect (arextract, "cancelled",
+ g_signal_connect (extractor, "cancelled",
G_CALLBACK (cancelled_handler), data);
data->conflict_files = g_hash_table_new_full (g_file_hash,
@@ -487,7 +487,7 @@ test_one_file_same_name (void)
ExtractTest *extract_test;
ExtractTestData *data;
g_autoptr (GFile) archive = NULL;
- g_autoptr (AutoarExtract) arextract = NULL;
+ g_autoptr (AutoarExtractor) extractor = NULL;
extract_test = extract_test_new ("test-one-file-same-name");
@@ -498,11 +498,11 @@ test_one_file_same_name (void)
archive = g_file_get_child (extract_test->in, "arextract.zip");
- arextract = autoar_extract_new (archive, extract_test->out);
+ extractor = autoar_extractor_new (archive, extract_test->out);
- data = extract_test_data_new_for_extract (arextract);
+ data = extract_test_data_new_for_extract (extractor);
- autoar_extract_start (arextract, data->cancellable);
+ autoar_extractor_start (extractor, data->cancellable);
g_assert_cmpuint (data->number_of_files, ==, 1);
g_assert_no_error (data->error);
@@ -532,7 +532,7 @@ test_one_file_different_name (void)
ExtractTest *extract_test;
ExtractTestData *data;
g_autoptr (GFile) archive = NULL;
- g_autoptr (AutoarExtract) arextract = NULL;
+ g_autoptr (AutoarExtractor) extractor = NULL;
extract_test = extract_test_new ("test-one-file-different-name");
@@ -543,11 +543,11 @@ test_one_file_different_name (void)
archive = g_file_get_child (extract_test->in, "arextract.zip");
- arextract = autoar_extract_new (archive, extract_test->out);
+ extractor = autoar_extractor_new (archive, extract_test->out);
- data = extract_test_data_new_for_extract (arextract);
+ data = extract_test_data_new_for_extract (extractor);
- autoar_extract_start (arextract, data->cancellable);
+ autoar_extractor_start (extractor, data->cancellable);
g_assert_cmpuint (data->number_of_files, ==, 1);
g_assert_no_error (data->error);
@@ -582,7 +582,7 @@ test_multiple_files_same_name (void)
ExtractTest *extract_test;
ExtractTestData *data;
g_autoptr (GFile) archive = NULL;
- g_autoptr (AutoarExtract) arextract = NULL;
+ g_autoptr (AutoarExtractor) extractor = NULL;
extract_test = extract_test_new ("test-multiple-files-same-name");
@@ -593,11 +593,11 @@ test_multiple_files_same_name (void)
archive = g_file_get_child (extract_test->in, "arextract.zip");
- arextract = autoar_extract_new (archive, extract_test->out);
+ extractor = autoar_extractor_new (archive, extract_test->out);
- data = extract_test_data_new_for_extract (arextract);
+ data = extract_test_data_new_for_extract (extractor);
- autoar_extract_start (arextract, data->cancellable);
+ autoar_extractor_start (extractor, data->cancellable);
g_assert_cmpuint (data->number_of_files, ==, 4);
g_assert_no_error (data->error);
@@ -635,7 +635,7 @@ test_multiple_files_different_name (void)
ExtractTest *extract_test;
ExtractTestData *data;
g_autoptr (GFile) archive = NULL;
- g_autoptr (AutoarExtract) arextract = NULL;
+ g_autoptr (AutoarExtractor) extractor = NULL;
extract_test = extract_test_new ("test-multiple-files-different-name");
@@ -646,11 +646,11 @@ test_multiple_files_different_name (void)
archive = g_file_get_child (extract_test->in, "arextract.zip");
- arextract = autoar_extract_new (archive, extract_test->out);
+ extractor = autoar_extractor_new (archive, extract_test->out);
- data = extract_test_data_new_for_extract (arextract);
+ data = extract_test_data_new_for_extract (extractor);
- autoar_extract_start (arextract, data->cancellable);
+ autoar_extractor_start (extractor, data->cancellable);
g_assert_cmpuint (data->number_of_files, ==, 5);
g_assert_no_error (data->error);
@@ -681,7 +681,7 @@ test_one_file_conflict_overwrite (void)
g_autoptr (GFile) archive = NULL;
g_autoptr (GFile) conflict_file = NULL;
g_autoptr (GFile) reference_file = NULL;
- g_autoptr (AutoarExtract) arextract = NULL;
+ g_autoptr (AutoarExtractor) extractor = NULL;
extract_test = extract_test_new ("test-one-file-conflict-overwrite");
@@ -700,11 +700,11 @@ test_one_file_conflict_overwrite (void)
archive = g_file_get_child (extract_test->in, "arextract.zip");
- arextract = autoar_extract_new (archive, extract_test->out);
+ extractor = autoar_extractor_new (archive, extract_test->out);
- data = extract_test_data_new_for_extract (arextract);
+ data = extract_test_data_new_for_extract (extractor);
- autoar_extract_start (arextract, data->cancellable);
+ autoar_extractor_start (extractor, data->cancellable);
g_assert_cmpuint (data->number_of_files, ==, 1);
g_assert_true (g_hash_table_contains (data->conflict_files,
@@ -738,7 +738,7 @@ test_one_file_conflict_new_destination (void)
g_autoptr (GFile) archive = NULL;
g_autoptr (GFile) conflict_file = NULL;
g_autoptr (GFile) reference_file = NULL;
- g_autoptr (AutoarExtract) arextract = NULL;
+ g_autoptr (AutoarExtractor) extractor = NULL;
extract_test = extract_test_new ("test-one-file-conflict-new-destination");
@@ -757,9 +757,9 @@ test_one_file_conflict_new_destination (void)
archive = g_file_get_child (extract_test->in, "arextract.zip");
- arextract = autoar_extract_new (archive, extract_test->out);
+ extractor = autoar_extractor_new (archive, extract_test->out);
- data = extract_test_data_new_for_extract (arextract);
+ data = extract_test_data_new_for_extract (extractor);
g_hash_table_insert (data->conflict_files_actions,
g_object_ref (conflict_file),
@@ -770,7 +770,7 @@ test_one_file_conflict_new_destination (void)
g_file_get_child (extract_test->out,
"arextract_new.txt"));
- autoar_extract_start (arextract, data->cancellable);
+ autoar_extractor_start (extractor, data->cancellable);
g_assert_cmpuint (data->number_of_files, ==, 1);
g_assert_true (g_hash_table_contains (data->conflict_files,
@@ -803,7 +803,7 @@ test_one_file_conflict_skip_file (void)
g_autoptr (GFile) archive = NULL;
g_autoptr (GFile) conflict_file = NULL;
g_autoptr (GFile) reference_file = NULL;
- g_autoptr (AutoarExtract) arextract = NULL;
+ g_autoptr (AutoarExtractor) extractor = NULL;
extract_test = extract_test_new ("test-one-file-conflict-skip-file");
@@ -822,15 +822,15 @@ test_one_file_conflict_skip_file (void)
archive = g_file_get_child (extract_test->in, "arextract.zip");
- arextract = autoar_extract_new (archive, extract_test->out);
+ extractor = autoar_extractor_new (archive, extract_test->out);
- data = extract_test_data_new_for_extract (arextract);
+ data = extract_test_data_new_for_extract (extractor);
g_hash_table_insert (data->conflict_files_actions,
g_object_ref (conflict_file),
GUINT_TO_POINTER (AUTOAR_CONFLICT_SKIP));
- autoar_extract_start (arextract, data->cancellable);
+ autoar_extractor_start (extractor, data->cancellable);
g_assert_cmpuint (data->number_of_files, ==, 1);
g_assert_true (g_hash_table_contains (data->conflict_files,
@@ -868,7 +868,7 @@ test_one_file_error_file_over_directory (void)
g_autoptr (GFile) conflict_directory = NULL;
g_autoptr (GFile) dummy_file = NULL;
g_autoptr (GFileOutputStream) out = NULL;
- g_autoptr (AutoarExtract) arextract = NULL;
+ g_autoptr (AutoarExtractor) extractor = NULL;
extract_test = extract_test_new ("test-one-file-error-file-over-directory");
@@ -888,11 +888,11 @@ test_one_file_error_file_over_directory (void)
archive = g_file_get_child (extract_test->in, "arextract.zip");
- arextract = autoar_extract_new (archive, extract_test->out);
+ extractor = autoar_extractor_new (archive, extract_test->out);
- data = extract_test_data_new_for_extract (arextract);
+ data = extract_test_data_new_for_extract (extractor);
- autoar_extract_start (arextract, data->cancellable);
+ autoar_extractor_start (extractor, data->cancellable);
g_assert_cmpuint (data->number_of_files, ==, 1);
g_assert_true (g_hash_table_contains (data->conflict_files,
@@ -929,7 +929,7 @@ test_change_extract_destination (void)
ExtractTest *extract_test;
ExtractTestData *data;
g_autoptr (GFile) archive = NULL;
- g_autoptr (AutoarExtract) arextract = NULL;
+ g_autoptr (AutoarExtractor) extractor = NULL;
extract_test = extract_test_new ("test-change-extract-destination");
@@ -940,13 +940,13 @@ test_change_extract_destination (void)
archive = g_file_get_child (extract_test->in, "arextract.zip");
- arextract = autoar_extract_new (archive, extract_test->out);
+ extractor = autoar_extractor_new (archive, extract_test->out);
- data = extract_test_data_new_for_extract (arextract);
+ data = extract_test_data_new_for_extract (extractor);
data->destination_to_suggest = g_file_get_child (extract_test->out,
"new_destination");
- autoar_extract_start (arextract, data->cancellable);
+ autoar_extractor_start (extractor, data->cancellable);
g_assert_cmpuint (data->number_of_files, ==, 4);
g_assert_no_error (data->error);
diff --git a/tests/test-extract.c b/tests/test-extract.c
index a749d12..a1465af 100644
--- a/tests/test-extract.c
+++ b/tests/test-extract.c
@@ -6,7 +6,7 @@
#include <stdlib.h>
static void
-my_handler_scanned (AutoarExtract *arextract,
+my_handler_scanned (AutoarExtractor *extractor,
guint files,
gpointer data)
{
@@ -14,7 +14,7 @@ my_handler_scanned (AutoarExtract *arextract,
}
static GFile*
-my_handler_decide_destination (AutoarExtract *arextract,
+my_handler_decide_destination (AutoarExtractor *extractor,
GFile *dest,
GList *files,
gpointer data)
@@ -43,18 +43,18 @@ my_handler_decide_destination (AutoarExtract *arextract,
}
static void
-my_handler_progress (AutoarExtract *arextract,
+my_handler_progress (AutoarExtractor *extractor,
guint64 completed_size,
guint completed_files,
gpointer data)
{
g_print ("\rProgress: Archive Size %.2lf %%, Files %.2lf %%",
- ((double)(completed_size)) * 100 / autoar_extract_get_size (arextract),
- ((double)(completed_files)) * 100 / autoar_extract_get_files (arextract));
+ ((double)(completed_size)) * 100 / autoar_extractor_get_size (extractor),
+ ((double)(completed_files)) * 100 / autoar_extractor_get_files (extractor));
}
static AutoarConflictAction
-my_handler_conflict (AutoarExtract *arextract,
+my_handler_conflict (AutoarExtractor *extractor,
GFile *file,
GFile **new_file,
gpointer data)
@@ -69,7 +69,7 @@ my_handler_conflict (AutoarExtract *arextract,
}
static void
-my_handler_error (AutoarExtract *arextract,
+my_handler_error (AutoarExtractor *extractor,
GError *error,
gpointer data)
{
@@ -77,7 +77,7 @@ my_handler_error (AutoarExtract *arextract,
}
static void
-my_handler_completed (AutoarExtract *arextract,
+my_handler_completed (AutoarExtractor *extractor,
gpointer data)
{
g_print ("\nCompleted!\n");
@@ -87,7 +87,7 @@ int
main (int argc,
char *argv[])
{
- AutoarExtract *arextract;
+ AutoarExtractor *extractor;
char *content;
g_autoptr (GFile) source = NULL;
g_autoptr (GFile) output = NULL;
@@ -104,18 +104,18 @@ main (int argc,
source = g_file_new_for_commandline_arg (argv[1]);
output = g_file_new_for_commandline_arg (argv[2]);
- arextract = autoar_extract_new (source, output);
+ extractor = autoar_extractor_new (source, output);
- g_signal_connect (arextract, "scanned", G_CALLBACK (my_handler_scanned), NULL);
- g_signal_connect (arextract, "decide-destination", G_CALLBACK (my_handler_decide_destination), NULL);
- g_signal_connect (arextract, "progress", G_CALLBACK (my_handler_progress), NULL);
- g_signal_connect (arextract, "conflict", G_CALLBACK (my_handler_conflict), NULL);
- g_signal_connect (arextract, "error", G_CALLBACK (my_handler_error), NULL);
- g_signal_connect (arextract, "completed", G_CALLBACK (my_handler_completed), NULL);
+ g_signal_connect (extractor, "scanned", G_CALLBACK (my_handler_scanned), NULL);
+ g_signal_connect (extractor, "decide-destination", G_CALLBACK (my_handler_decide_destination), NULL);
+ g_signal_connect (extractor, "progress", G_CALLBACK (my_handler_progress), NULL);
+ g_signal_connect (extractor, "conflict", G_CALLBACK (my_handler_conflict), NULL);
+ g_signal_connect (extractor, "error", G_CALLBACK (my_handler_error), NULL);
+ g_signal_connect (extractor, "completed", G_CALLBACK (my_handler_completed), NULL);
- autoar_extract_start (arextract, NULL);
+ autoar_extractor_start (extractor, NULL);
- g_object_unref (arextract);
+ g_object_unref (extractor);
g_free (content);
return 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]