[gnome-autoar] AutoarExtract: rename to AutoarExtractor
- From: Răzvan-Mihai Chițu <razvanchitu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-autoar] AutoarExtract: rename to AutoarExtractor
- Date: Mon, 22 Aug 2016 09:45:27 +0000 (UTC)
commit 231a29ff801c842582a674b6e79b551ca643ac80
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 | 84 --
.../{autoar-extract.c => autoar-extractor.c} | 1120 ++++++++++----------
gnome-autoar/autoar-extractor.h | 84 ++
gnome-autoar/autoar.h | 2 +-
tests/test-extract-unit.c | 102 +-
tests/test-extract.c | 38 +-
7 files changed, 728 insertions(+), 706 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 55%
rename from gnome-autoar/autoar-extract.c
rename to gnome-autoar/autoar-extractor.c
index 8bf8c02..f08a272 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 *self;
- arextract = AUTOAR_EXTRACT (object);
+ self = AUTOAR_EXTRACTOR (object);
switch (property_id) {
case PROP_SOURCE_FILE:
- g_value_set_object (value, arextract->source_file);
+ g_value_set_object (value, self->source_file);
break;
case PROP_OUTPUT_FILE:
- g_value_set_object (value, arextract->output_file);
+ g_value_set_object (value, self->output_file);
break;
case PROP_SIZE:
- g_value_set_uint64 (value, arextract->size);
+ g_value_set_uint64 (value, self->size);
break;
case PROP_COMPLETED_SIZE:
- g_value_set_uint64 (value, arextract->completed_size);
+ g_value_set_uint64 (value, self->completed_size);
break;
case PROP_FILES:
- g_value_set_uint (value, arextract->files);
+ g_value_set_uint (value, self->files);
break;
case PROP_COMPLETED_FILES:
- g_value_set_uint (value, arextract->completed_files);
+ g_value_set_uint (value, self->completed_files);
break;
case PROP_OUTPUT_IS_DEST:
- g_value_set_boolean (value, arextract->output_is_dest);
+ g_value_set_boolean (value, self->output_is_dest);
break;
case PROP_DELETE_AFTER_EXTRACTION:
- g_value_set_boolean (value, arextract->delete_after_extraction);
+ g_value_set_boolean (value, self->delete_after_extraction);
break;
case PROP_NOTIFY_INTERVAL:
- g_value_set_int64 (value, arextract->notify_interval);
+ g_value_set_int64 (value, self->notify_interval);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -228,33 +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 *self;
- arextract = AUTOAR_EXTRACT (object);
+ self = 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 (&(self->source_file));
+ self->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 (&(self->output_file));
+ self->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 (self,
+ g_value_get_boolean (value));
break;
case PROP_DELETE_AFTER_EXTRACTION:
- autoar_extract_set_delete_after_extraction (arextract,
- g_value_get_boolean (value));
+ autoar_extractor_set_delete_after_extraction (self,
+ 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 (self,
+ g_value_get_int64 (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -263,8 +265,8 @@ autoar_extract_set_property (GObject *object,
}
/**
- * autoar_extract_get_source_file:
- * @arextract: an #AutoarExtract
+ * autoar_extractor_get_source_file:
+ * @self: an #AutoarExtractor
*
* Gets the #GFile object which represents the source archive that will be
* extracted for this object.
@@ -272,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 *self)
{
- g_return_val_if_fail (AUTOAR_IS_EXTRACT (arextract), NULL);
- return arextract->source_file;
+ g_return_val_if_fail (AUTOAR_IS_EXTRACTOR (self), NULL);
+ return self->source_file;
}
/**
- * autoar_extract_get_output_file:
- * @arextract: an #AutoarExtract
+ * autoar_extractor_get_output_file:
+ * @self: 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 *self)
{
- g_return_val_if_fail (AUTOAR_IS_EXTRACT (arextract), NULL);
- return arextract->output_file;
+ g_return_val_if_fail (AUTOAR_IS_EXTRACTOR (self), NULL);
+ return self->output_file;
}
/**
- * autoar_extract_get_size:
- * @arextract: an #AutoarExtract
+ * autoar_extractor_get_size:
+ * @self: 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 *self)
{
- g_return_val_if_fail (AUTOAR_IS_EXTRACT (arextract), 0);
- return arextract->size;
+ g_return_val_if_fail (AUTOAR_IS_EXTRACTOR (self), 0);
+ return self->size;
}
/**
- * autoar_extract_get_completed_size:
- * @arextract: an #AutoarExtract
+ * autoar_extractor_get_completed_size:
+ * @self: 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 *self)
{
- g_return_val_if_fail (AUTOAR_IS_EXTRACT (arextract), 0);
- return arextract->completed_size;
+ g_return_val_if_fail (AUTOAR_IS_EXTRACTOR (self), 0);
+ return self->completed_size;
}
/**
- * autoar_extract_get_files:
- * @arextract: an #AutoarExtract
+ * autoar_extractor_get_files:
+ * @self: an #AutoarExtractor
*
* Gets the total number of files will be written when the operation is
* completed.
@@ -334,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 *self)
{
- g_return_val_if_fail (AUTOAR_IS_EXTRACT (arextract), 0);
- return arextract->files;
+ g_return_val_if_fail (AUTOAR_IS_EXTRACTOR (self), 0);
+ return self->files;
}
/**
- * autoar_extract_get_completed_files:
- * @arextract: an #AutoarExtract
+ * autoar_extractor_get_completed_files:
+ * @self: 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 *self)
{
- g_return_val_if_fail (AUTOAR_IS_EXTRACT (arextract), 0);
- return arextract->completed_files;
+ g_return_val_if_fail (AUTOAR_IS_EXTRACTOR (self), 0);
+ return self->completed_files;
}
/**
- * autoar_extract_get_output_is_dest:
- * @arextract: an #AutoarExtract
+ * autoar_extractor_get_output_is_dest:
+ * @self: 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 *self)
{
- g_return_val_if_fail (AUTOAR_IS_EXTRACT (arextract), FALSE);
- return arextract->output_is_dest;
+ g_return_val_if_fail (AUTOAR_IS_EXTRACTOR (self), FALSE);
+ return self->output_is_dest;
}
/**
- * autoar_extract_get_delete_after_extraction:
- * @arextract: an #AutoarExtract
+ * autoar_extractor_get_delete_after_extraction:
+ * @self: an #AutoarExtractor
*
* Whether the source archive will be deleted after a successful extraction.
*
@@ -381,180 +383,180 @@ autoar_extract_get_output_is_dest (AutoarExtract *arextract)
* extraction
**/
gboolean
-autoar_extract_get_delete_after_extraction (AutoarExtract *arextract)
+autoar_extractor_get_delete_after_extraction (AutoarExtractor *self)
{
- g_return_val_if_fail (AUTOAR_IS_EXTRACT (arextract), FALSE);
- return arextract->delete_after_extraction;
+ g_return_val_if_fail (AUTOAR_IS_EXTRACTOR (self), FALSE);
+ return self->delete_after_extraction;
}
/**
- * autoar_extract_get_notify_interval:
- * @arextract: an #AutoarExtract
+ * autoar_extractor_get_notify_interval:
+ * @self: 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 *self)
{
- g_return_val_if_fail (AUTOAR_IS_EXTRACT (arextract), 0);
- return arextract->notify_interval;
+ g_return_val_if_fail (AUTOAR_IS_EXTRACTOR (self), 0);
+ return self->notify_interval;
}
/**
- * autoar_extract_set_output_is_dest:
- * @arextract: an #AutoarExtract
+ * autoar_extractor_set_output_is_dest:
+ * @self: 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 will be notified via #AutoarExtract::decide-destination, when it
- * is possible to set a new 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 will be notified via #AutoarExtractor::decide-destination, when
+ * it is possible to set a new destination.
*
- * #AutoarExtract will attempt to create the destination regardless to whether
+ * #AutoarExtractor will attempt to create the destination 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 *self,
+ 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 (self));
+ self->output_is_dest = output_is_dest;
}
/**
- * autoar_extract_set_delete_after_extraction:
- * @arextract: an #AutoarExtract
- * @delete_after_extraction: %TRUE if the source archive should be deleted after
- * a successful extraction
+ * autoar_extractor_set_delete_after_extraction:
+ * @self: an #AutoarExtractor
+ * @delete_after_extraction: %TRUE if the source archive should be deleted
+ * after a successful extraction
*
- * By default #AutoarExtract:delete-after-extraction is set to %FALSE so the
+ * By default #AutoarExtractor:delete-after-extraction is set to %FALSE so the
* source archive will not be automatically deleted if extraction succeeds.
**/
void
-autoar_extract_set_delete_after_extraction (AutoarExtract *arextract,
- gboolean delete_after_extraction)
+autoar_extractor_set_delete_after_extraction (AutoarExtractor *self,
+ gboolean delete_after_extraction)
{
- g_return_if_fail (AUTOAR_IS_EXTRACT (arextract));
- arextract->delete_after_extraction = delete_after_extraction;
+ g_return_if_fail (AUTOAR_IS_EXTRACTOR (self));
+ self->delete_after_extraction = delete_after_extraction;
}
/**
- * autoar_extract_set_notify_interval:
- * @arextract: an #AutoarExtract
+ * autoar_extractor_set_notify_interval:
+ * @self: 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 *self,
+ gint64 notify_interval)
{
- g_return_if_fail (AUTOAR_IS_EXTRACT (arextract));
+ g_return_if_fail (AUTOAR_IS_EXTRACTOR (self));
g_return_if_fail (notify_interval >= 0);
- arextract->notify_interval = notify_interval;
+ self->notify_interval = notify_interval;
}
static void
-autoar_extract_dispose (GObject *object)
+autoar_extractor_dispose (GObject *object)
{
- AutoarExtract *arextract;
+ AutoarExtractor *self;
- arextract = AUTOAR_EXTRACT (object);
+ self = 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 (self->istream != NULL) {
+ if (!g_input_stream_is_closed (self->istream)) {
+ g_input_stream_close (self->istream, self->cancellable, NULL);
}
- g_object_unref (arextract->istream);
- arextract->istream = NULL;
+ g_object_unref (self->istream);
+ self->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 (&(self->source_file));
+ g_clear_object (&(self->output_file));
+ g_clear_object (&(self->destination_dir));
+ g_clear_object (&(self->cancellable));
+ g_clear_object (&(self->prefix));
+ g_clear_object (&(self->new_prefix));
- g_list_free_full (arextract->files_list, g_object_unref);
- arextract->files_list = NULL;
+ g_list_free_full (self->files_list, g_object_unref);
+ self->files_list = NULL;
- if (arextract->userhash != NULL) {
- g_hash_table_unref (arextract->userhash);
- arextract->userhash = NULL;
+ if (self->userhash != NULL) {
+ g_hash_table_unref (self->userhash);
+ self->userhash = NULL;
}
- if (arextract->grouphash != NULL) {
- g_hash_table_unref (arextract->grouphash);
- arextract->grouphash = NULL;
+ if (self->grouphash != NULL) {
+ g_hash_table_unref (self->grouphash);
+ self->grouphash = NULL;
}
- if (arextract->extracted_dir_list != NULL) {
- g_array_unref (arextract->extracted_dir_list);
- arextract->extracted_dir_list = NULL;
+ if (self->extracted_dir_list != NULL) {
+ g_array_unref (self->extracted_dir_list);
+ self->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 *self;
- arextract = AUTOAR_EXTRACT (object);
+ self = AUTOAR_EXTRACTOR (object);
- g_debug ("AutoarExtract: finalize");
+ g_debug ("AutoarExtractor: finalize");
- g_free (arextract->buffer);
- arextract->buffer = NULL;
+ g_free (self->buffer);
+ self->buffer = NULL;
- if (arextract->error != NULL) {
- g_error_free (arextract->error);
- arextract->error = NULL;
+ if (self->error != NULL) {
+ g_error_free (self->error);
+ self->error = NULL;
}
- g_free (arextract->suggested_destname);
- arextract->suggested_destname = NULL;
+ g_free (self->suggested_destname);
+ self->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)
+ void *client_data)
{
- AutoarExtract *arextract;
+ AutoarExtractor *self;
GFileInputStream *istream;
g_debug ("libarchive_read_open_cb: called");
- arextract = AUTOAR_EXTRACT (client_data);
+ self = AUTOAR_EXTRACTOR (client_data);
- if (arextract->error != NULL)
+ if (self->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 (self->source_file,
+ self->cancellable,
+ &(self->error));
+ self->istream = G_INPUT_STREAM (istream);
- if (arextract->error != NULL)
+ if (self->error != NULL)
return ARCHIVE_FATAL;
g_debug ("libarchive_read_open_cb: ARCHIVE_OK");
@@ -563,21 +565,21 @@ libarchive_read_open_cb (struct archive *ar_read,
static int
libarchive_read_close_cb (struct archive *ar_read,
- void *client_data)
+ void *client_data)
{
- AutoarExtract *arextract;
+ AutoarExtractor *self;
g_debug ("libarchive_read_close_cb: called");
- arextract = AUTOAR_EXTRACT (client_data);
+ self = AUTOAR_EXTRACTOR (client_data);
- if (arextract->error != NULL)
+ if (self->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 (self->istream != NULL) {
+ g_input_stream_close (self->istream, self->cancellable, NULL);
+ g_object_unref (self->istream);
+ self->istream = NULL;
}
g_debug ("libarchive_read_close_cb: ARCHIVE_OK");
@@ -585,27 +587,27 @@ libarchive_read_close_cb (struct archive *ar_read,
}
static ssize_t
-libarchive_read_read_cb (struct archive *ar_read,
- void *client_data,
- const void **buffer)
+libarchive_read_read_cb (struct archive *ar_read,
+ void *client_data,
+ const void **buffer)
{
- AutoarExtract *arextract;
+ AutoarExtractor *self;
gssize read_size;
g_debug ("libarchive_read_read_cb: called");
- arextract = AUTOAR_EXTRACT (client_data);
+ self = AUTOAR_EXTRACTOR (client_data);
- if (arextract->error != NULL || arextract->istream == NULL)
+ if (self->error != NULL || self->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 = self->buffer;
+ read_size = g_input_stream_read (self->istream,
+ self->buffer,
+ self->buffer_size,
+ self->cancellable,
+ &(self->error));
+ if (self->error != NULL)
return -1;
g_debug ("libarchive_read_read_cb: %" G_GSSIZE_FORMAT, read_size);
@@ -614,20 +616,20 @@ libarchive_read_read_cb (struct archive *ar_read,
static gint64
libarchive_read_seek_cb (struct archive *ar_read,
- void *client_data,
- gint64 request,
- int whence)
+ void *client_data,
+ gint64 request,
+ int whence)
{
- AutoarExtract *arextract;
+ AutoarExtractor *self;
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)
+ self = AUTOAR_EXTRACTOR (client_data);
+ seekable = (GSeekable*)(self->istream);
+ if (self->error != NULL || self->istream == NULL)
return -1;
switch (whence) {
@@ -647,10 +649,10 @@ libarchive_read_seek_cb (struct archive *ar_read,
g_seekable_seek (seekable,
request,
seektype,
- arextract->cancellable,
- &(arextract->error));
+ self->cancellable,
+ &(self->error));
new_offset = g_seekable_tell (seekable);
- if (arextract->error != NULL)
+ if (self->error != NULL)
return -1;
g_debug ("libarchive_read_seek_cb: %"G_GOFFSET_FORMAT, (goffset)new_offset);
@@ -659,18 +661,18 @@ libarchive_read_seek_cb (struct archive *ar_read,
static gint64
libarchive_read_skip_cb (struct archive *ar_read,
- void *client_data,
- gint64 request)
+ void *client_data,
+ gint64 request)
{
- AutoarExtract *arextract;
+ AutoarExtractor *self;
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) {
+ self = AUTOAR_EXTRACTOR (client_data);
+ seekable = (GSeekable*)(self->istream);
+ if (self->error != NULL || self->istream == NULL) {
return -1;
}
@@ -683,9 +685,9 @@ libarchive_read_skip_cb (struct archive *ar_read,
}
static int
-libarchive_create_read_object (gboolean use_raw_format,
- AutoarExtract *arextract,
- struct archive **a)
+libarchive_create_read_object (gboolean use_raw_format,
+ AutoarExtractor *self,
+ struct archive **a)
{
*a = archive_read_new ();
archive_read_support_filter_all (*a);
@@ -698,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, self);
return archive_read_open1 (*a);
}
@@ -712,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 *self)
{
- autoar_common_g_signal_emit (arextract, arextract->in_thread,
- autoar_extract_signals[SCANNED], 0,
- arextract->files);
+ autoar_common_g_signal_emit (self, self->in_thread,
+ autoar_extractor_signals[SCANNED], 0,
+ self->files);
}
static inline void
-autoar_extract_signal_decide_destination (AutoarExtract *arextract,
- GFile *destination,
- GList *files,
- GFile **new_destination)
+autoar_extractor_signal_decide_destination (AutoarExtractor *self,
+ 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 (self, self->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 *self)
{
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 - self->notify_last >= self->notify_interval) {
+ autoar_common_g_signal_emit (self, self->in_thread,
+ autoar_extractor_signals[PROGRESS], 0,
+ self->completed_size,
+ self->completed_files);
+ self->notify_last = mtime;
}
}
static AutoarConflictAction
-autoar_extract_signal_conflict (AutoarExtract *arextract,
- GFile *file,
- GFile **new_file)
+autoar_extractor_signal_conflict (AutoarExtractor *self,
+ 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 (self, self->in_thread,
+ autoar_extractor_signals[CONFLICT], 0,
file,
new_file,
&action);
@@ -766,48 +768,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 *self)
{
- autoar_common_g_signal_emit (arextract, arextract->in_thread,
- autoar_extract_signals[CANCELLED], 0);
+ autoar_common_g_signal_emit (self, self->in_thread,
+ autoar_extractor_signals[CANCELLED], 0);
}
static inline void
-autoar_extract_signal_completed (AutoarExtract *arextract)
+autoar_extractor_signal_completed (AutoarExtractor *self)
{
- autoar_common_g_signal_emit (arextract, arextract->in_thread,
- autoar_extract_signals[COMPLETED], 0);
+ autoar_common_g_signal_emit (self, self->in_thread,
+ autoar_extractor_signals[COMPLETED], 0);
}
static inline void
-autoar_extract_signal_error (AutoarExtract *arextract)
+autoar_extractor_signal_error (AutoarExtractor *self)
{
- 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 (self->error != NULL) {
+ if (self->error->domain == G_IO_ERROR &&
+ self->error->code == G_IO_ERROR_CANCELLED) {
+ g_error_free (self->error);
+ self->error = NULL;
+ autoar_extractor_signal_cancelled (self);
} else {
- autoar_common_g_signal_emit (arextract, arextract->in_thread,
- autoar_extract_signals[AR_ERROR], 0,
- arextract->error);
+ autoar_common_g_signal_emit (self, self->in_thread,
+ autoar_extractor_signals[AR_ERROR], 0,
+ self->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;
@@ -841,17 +844,18 @@ 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 *self,
+ const char *pathname)
{
GFile *extracted_filename;
gboolean valid_filename;
g_autofree char *sanitized_pathname;
- extracted_filename = g_file_get_child (arextract->destination_dir, pathname);
+ extracted_filename = g_file_get_child (self->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, self->destination_dir) ||
+ g_file_has_prefix (extracted_filename, self->destination_dir);
if (!valid_filename) {
g_autofree char *basename;
@@ -860,33 +864,34 @@ 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 (self->destination_dir,
basename);
}
- if (arextract->prefix != NULL && arextract->new_prefix != NULL) {
+ if (self->prefix != NULL && self->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 (self->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 (self->new_prefix,
+ relative_path);
}
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;
@@ -922,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 *self,
+ struct archive *a,
+ struct archive_entry *entry,
+ GFile *dest,
+ GFile *hardlink)
{
GFileInfo *info;
mode_t filetype;
@@ -935,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, self->cancellable))
+ g_file_make_directory_with_parents (parent,
+ self->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,
@@ -982,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 (self->userhash, uname, NULL, &got_uid) == TRUE) {
uid = GPOINTER_TO_UINT (got_uid);
} else {
struct passwd *pwd = getpwnam (uname);
@@ -994,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 (self->userhash, g_strdup (uname), GUINT_TO_POINTER (uid));
}
}
g_file_info_set_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_UID, uid);
@@ -1011,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 (self->grouphash, gname, NULL, &got_gid) == TRUE) {
gid = GPOINTER_TO_UINT (got_gid);
} else {
struct group *grp = getgrnam (gname);
@@ -1023,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 (self->grouphash, g_strdup (gname), GUINT_TO_POINTER (gid));
}
}
g_file_info_set_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_GID, gid);
@@ -1036,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));
@@ -1046,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)) {
@@ -1069,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) {
+ self->cancellable,
+ &(self->error));
+ if (self->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 || self->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
@@ -1095,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);
+ self->cancellable,
+ &(self->error));
+ if (self->error != NULL) {
+ g_output_stream_close (ostream, self->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 (self->cancellable)) {
+ g_output_stream_close (ostream, self->cancellable, NULL);
g_object_unref (ostream);
g_object_unref (info);
return;
}
- arextract->completed_size += written;
- autoar_extract_signal_progress (arextract);
+ self->completed_size += written;
+ autoar_extractor_signal_progress (self);
}
}
- g_output_stream_close (ostream, arextract->cancellable, NULL);
+ g_output_stream_close (ostream, self->cancellable, NULL);
g_object_unref (ostream);
}
}
@@ -1122,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, self->cancellable, &(self->error));
- if (arextract->error != NULL) {
+ if (self->error != NULL) {
/* "File exists" is not a fatal error, as long as the existing file
* is a directory
*/
@@ -1136,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 (self->error, G_IO_ERROR, G_IO_ERROR_EXISTS) &&
file_type == G_FILE_TYPE_DIRECTORY) {
- g_clear_error (&arextract->error);
+ g_clear_error (&self->error);
} else {
g_object_unref (info);
return;
@@ -1147,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 (self->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));
+ self->cancellable,
+ &(self->error));
break;
/* FIFOs, sockets, block files, character files are not important
* in the regular archives, so errors are not fatal. */
@@ -1163,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
@@ -1179,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);
@@ -1189,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));
@@ -1199,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));
@@ -1216,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, self->cancellable, NULL);
if (ostream != NULL) {
- g_output_stream_close (ostream, arextract->cancellable, NULL);
+ g_output_stream_close (ostream, self->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));
+ self->cancellable,
+ &(self->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 (self->error != NULL) {
+ g_debug ("autoar_extractor_do_write_entry: %s\n", self->error->message);
+ g_error_free (self->error);
+ self->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;
@@ -1250,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",
@@ -1334,14 +1341,14 @@ autoar_extract_class_init (AutoarExtractClass *klass)
G_PARAM_STATIC_STRINGS));
/**
- * AutoarExtract::scanned:
- * @arextract: the #AutoarExtract
+ * AutoarExtractor::scanned:
+ * @self: 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,
@@ -1352,8 +1359,8 @@ autoar_extract_class_init (AutoarExtractClass *klass)
G_TYPE_UINT);
/**
- * AutoarExtract::decide-destination:
- * @arextract: the #AutoarExtract
+ * AutoarExtractor::decide-destination:
+ * @self: 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
@@ -1365,7 +1372,7 @@ autoar_extract_class_init (AutoarExtractClass *klass)
* 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,
@@ -1377,14 +1384,14 @@ autoar_extract_class_init (AutoarExtractClass *klass)
G_TYPE_POINTER);
/**
- * AutoarExtract::progress:
- * @arextract: the #AutoarExtract
+ * AutoarExtractor::progress:
+ * @self: 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,
@@ -1396,17 +1403,17 @@ autoar_extract_class_init (AutoarExtractClass *klass)
G_TYPE_UINT);
/**
- * AutoarExtract::conflict:
- * @arextract: the #AutoarExtract
+ * AutoarExtractor::conflict:
+ * @self: 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,
@@ -1418,13 +1425,13 @@ autoar_extract_class_init (AutoarExtractClass *klass)
G_TYPE_POINTER);
/**
- * AutoarExtract::cancelled:
- * @arextract: the #AutoarExtract
+ * AutoarExtractor::cancelled:
+ * @self: 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,
@@ -1434,13 +1441,13 @@ autoar_extract_class_init (AutoarExtractClass *klass)
0);
/**
- * AutoarExtract::completed:
- * @arextract: the #AutoarExtract
+ * AutoarExtractor::completed:
+ * @self: 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,
@@ -1450,17 +1457,17 @@ autoar_extract_class_init (AutoarExtractClass *klass)
0);
/**
- * AutoarExtract::error:
- * @arextract: the #AutoarExtract
+ * AutoarExtractor::error:
+ * @self: 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,
@@ -1472,71 +1479,71 @@ autoar_extract_class_init (AutoarExtractClass *klass)
}
static void
-autoar_extract_init (AutoarExtract *arextract)
+autoar_extractor_init (AutoarExtractor *self)
{
- arextract->cancellable = NULL;
+ self->cancellable = NULL;
- arextract->size = 0;
- arextract->completed_size = 0;
+ self->size = 0;
+ self->completed_size = 0;
- arextract->files_list = NULL;
+ self->files_list = NULL;
- arextract->files = 0;
- arextract->completed_files = 0;
+ self->files = 0;
+ self->completed_files = 0;
- arextract->notify_last = 0;
+ self->notify_last = 0;
- arextract->istream = NULL;
- arextract->buffer_size = BUFFER_SIZE;
- arextract->buffer = g_new (char, arextract->buffer_size);
- arextract->error = NULL;
+ self->istream = NULL;
+ self->buffer_size = BUFFER_SIZE;
+ self->buffer = g_new (char, self->buffer_size);
+ self->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;
+ self->userhash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ self->grouphash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ self->extracted_dir_list = g_array_new (FALSE, FALSE, sizeof (GFileAndInfo));
+ g_array_set_clear_func (self->extracted_dir_list, g_file_and_info_free);
+ self->destination_dir = NULL;
+ self->new_prefix = NULL;
- arextract->suggested_destname = NULL;
+ self->suggested_destname = NULL;
- arextract->in_thread = FALSE;
- arextract->use_raw_format = FALSE;
+ self->in_thread = FALSE;
+ self->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 *self;
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,
- "source-file", source_file,
- "output-file", output_file,
- NULL);
+ self = 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);
+ self->source_basename = g_file_get_basename (self->source_file);
+ self->suggested_destname = autoar_common_get_basename_remove_extension (self->source_basename);
- return arextract;
+ return self;
}
static void
-autoar_extract_step_scan_toplevel (AutoarExtract *arextract)
+autoar_extractor_step_scan_toplevel (AutoarExtractor *self)
{
/* Step 0: Scan all file names in the archive
* We have to check whether the archive contains a top-level directory
@@ -1548,58 +1555,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, self, &a);
if (r != ARCHIVE_OK) {
archive_read_free (a);
- r = libarchive_create_read_object (TRUE, arextract, &a);
+ r = libarchive_create_read_object (TRUE, self, &a);
if (r != ARCHIVE_OK) {
- if (arextract->error == NULL)
- arextract->error = autoar_common_g_error_new_a (a, arextract->source_basename);
+ if (self->error == NULL)
+ self->error = autoar_common_g_error_new_a (a, self->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 (self->error == NULL)
+ self->error = g_error_new (AUTOAR_EXTRACTOR_ERROR,
+ NOT_AN_ARCHIVE_ERRNO,
+ "\'%s\': %s",
+ self->source_basename,
+ "not an archive");
return;
}
- arextract->use_raw_format = TRUE;
+ self->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 (self->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",
+ self->files, pathname);
+
+ self->files_list =
+ g_list_prepend (self->files_list,
+ g_file_get_child (self->output_file, pathname));
+ self->files++;
+ self->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 (self->files_list == NULL) {
+ if (self->error == NULL) {
+ self->error = g_error_new (AUTOAR_EXTRACTOR_ERROR,
+ EMPTY_ARCHIVE_ERRNO,
+ "\'%s\': %s",
+ self->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 (self->error == NULL) {
+ self->error =
+ autoar_common_g_error_new_a (a, self->source_basename);
}
archive_read_free (a);
return;
@@ -1607,40 +1623,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 (self->size <= 0)
+ self->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", self->files);
- arextract->files_list = g_list_reverse (arextract->files_list);
+ self->files_list = g_list_reverse (self->files_list);
- arextract->prefix = autoar_extract_get_common_prefix (arextract->files_list, arextract->output_file);
+ self->prefix =
+ autoar_extractor_get_common_prefix (self->files_list,
+ self->output_file);
- if (arextract->prefix != NULL) {
+ if (self->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 (self->prefix);
+ g_debug ("autoar_extractor_step_scan_toplevel: pathname_prefix = %s",
+ path_prefix);
}
- autoar_extract_signal_scanned (arextract);
+ autoar_extractor_signal_scanned (self);
}
static void
-autoar_extract_step_set_destination (AutoarExtract *arextract)
+autoar_extractor_step_set_destination (AutoarExtractor *self)
{
/* Step 1: Set destination based on client preferences or archive contents */
- g_debug ("autoar_extract_step_set_destination: called");
+ g_debug ("autoar_extractor_step_set_destination: called");
- if (arextract->output_is_dest) {
- arextract->destination_dir = g_object_ref (arextract->output_file);
+ if (self->output_is_dest) {
+ self->destination_dir = g_object_ref (self->output_file);
return;
}
- if (arextract->prefix != NULL) {
+ if (self->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.
@@ -1648,26 +1667,26 @@ autoar_extract_step_set_destination (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 (self->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, self->suggested_destname) == 0) {
+ self->destination_dir = g_object_ref (self->output_file);
} else {
- g_clear_object (&arextract->prefix);
+ g_clear_object (&self->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 (self->destination_dir == NULL) {
+ self->destination_dir = g_file_get_child (self->output_file,
+ self->suggested_destname);
}
}
static void
-autoar_extract_step_decide_destination (AutoarExtract *arextract)
+autoar_extractor_step_decide_destination (AutoarExtractor *self)
{
/* Step 2: Decide destination */
@@ -1676,12 +1695,12 @@ autoar_extract_step_decide_destination (AutoarExtract *arextract)
GFile *new_destination = NULL;
g_autofree char *destination_name;
- for (l = arextract->files_list; l != NULL; l = l->next) {
+ for (l = self->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 (self->output_file, l->data);
+ file = g_file_resolve_relative_path (self->destination_dir,
relative_path);
files = g_list_prepend (files, file);
@@ -1694,44 +1713,45 @@ autoar_extract_step_decide_destination (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 (self->prefix != NULL) {
+ autoar_extractor_signal_decide_destination (self,
+ self->prefix,
+ files,
+ &new_destination);
- arextract->new_prefix = new_destination;
+ self->new_prefix = new_destination;
} else {
- autoar_extract_signal_decide_destination (arextract,
- arextract->destination_dir,
- files,
- &new_destination);
+ autoar_extractor_signal_decide_destination (self,
+ self->destination_dir,
+ files,
+ &new_destination);
if (new_destination) {
- g_object_unref (arextract->destination_dir);
- arextract->destination_dir = new_destination;
+ g_object_unref (self->destination_dir);
+ self->destination_dir = new_destination;
}
}
- destination_name = g_file_get_path (arextract->new_prefix != NULL ?
- arextract->new_prefix :
- arextract->destination_dir);
- g_debug ("autoar_extract_step_decide_destination: destination %s", destination_name);
+ destination_name = g_file_get_path (self->new_prefix != NULL ?
+ self->new_prefix :
+ self->destination_dir);
+ g_debug ("autoar_extractor_step_decide_destination: destination %s", destination_name);
- g_file_make_directory_with_parents (arextract->destination_dir, arextract->cancellable,
- &(arextract->error));
+ g_file_make_directory_with_parents (self->destination_dir,
+ self->cancellable,
+ &(self->error));
- if (g_error_matches (arextract->error, G_IO_ERROR, G_IO_ERROR_EXISTS)) {
+ if (g_error_matches (self->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 (self->destination_dir,
G_FILE_QUERY_INFO_NONE,
NULL);
if (file_type == G_FILE_TYPE_DIRECTORY) {
/* FIXME: Implement a way to solve directory conflicts */
- g_debug ("autoar_extract_step_decide_destination: destination directory exists");
- g_clear_error (&arextract->error);
+ g_debug ("autoar_extractor_step_decide_destination: destination directory exists");
+ g_clear_error (&self->error);
}
}
@@ -1739,7 +1759,7 @@ autoar_extract_step_decide_destination (AutoarExtract *arextract)
}
static void
-autoar_extract_step_extract (AutoarExtract *arextract) {
+autoar_extractor_step_extract (AutoarExtractor *self) {
/* Step 3: Extract files
* We have to re-open the archive to extract files
*/
@@ -1749,12 +1769,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 (self->use_raw_format, self, &a);
if (r != ARCHIVE_OK) {
- if (arextract->error == NULL) {
- arextract->error = autoar_common_g_error_new_a (a, arextract->source_basename);
+ if (self->error == NULL) {
+ self->error =
+ autoar_common_g_error_new_a (a, self->source_basename);
}
archive_read_free (a);
return;
@@ -1768,7 +1789,7 @@ autoar_extract_step_extract (AutoarExtract *arextract) {
AutoarConflictAction action;
gboolean file_conflict;
- if (g_cancellable_is_cancelled (arextract->cancellable)) {
+ if (g_cancellable_is_cancelled (self->cancellable)) {
archive_read_free (a);
return;
}
@@ -1777,22 +1798,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 (self, pathname);
if (hardlink != NULL) {
hardlink_filename =
- autoar_extract_do_sanitize_pathname (arextract, hardlink);
+ autoar_extractor_do_sanitize_pathname (self, hardlink);
}
/* Attempt to solve any name conflict before doing any operations */
- file_conflict = autoar_extract_check_file_conflict (extracted_filename,
- archive_entry_filetype (entry));
+ file_conflict = autoar_extractor_check_file_conflict (extracted_filename,
+ archive_entry_filetype (entry));
while (file_conflict) {
GFile *new_extracted_filename = NULL;
- action = autoar_extract_signal_conflict (arextract,
- extracted_filename,
- &new_extracted_filename);
+ action = autoar_extractor_signal_conflict (self,
+ extracted_filename,
+ &new_extracted_filename);
switch (action) {
case AUTOAR_CONFLICT_OVERWRITE:
@@ -1814,29 +1835,30 @@ autoar_extract_step_extract (AutoarExtract *arextract) {
break;
}
- file_conflict = autoar_extract_check_file_conflict (extracted_filename,
- archive_entry_filetype (entry));
+ file_conflict = autoar_extractor_check_file_conflict (extracted_filename,
+ archive_entry_filetype (entry));
}
if (file_conflict && action == AUTOAR_CONFLICT_SKIP) {
continue;
}
- autoar_extract_do_write_entry (arextract, a, entry,
- extracted_filename, hardlink_filename);
+ autoar_extractor_do_write_entry (self, a, entry,
+ extracted_filename, hardlink_filename);
- if (arextract->error != NULL) {
+ if (self->error != NULL) {
archive_read_free (a);
return;
}
- arextract->completed_files++;
- autoar_extract_signal_progress (arextract);
+ self->completed_files++;
+ autoar_extractor_signal_progress (self);
}
if (r != ARCHIVE_EOF) {
- if (arextract->error == NULL) {
- arextract->error = autoar_common_g_error_new_a (a, arextract->source_basename);
+ if (self->error == NULL) {
+ self->error =
+ autoar_common_g_error_new_a (a, self->source_basename);
}
archive_read_free (a);
return;
@@ -1846,7 +1868,7 @@ autoar_extract_step_extract (AutoarExtract *arextract) {
}
static void
-autoar_extract_step_apply_dir_fileinfo (AutoarExtract *arextract) {
+autoar_extractor_step_apply_dir_fileinfo (AutoarExtractor *self) {
/* 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.
@@ -1854,143 +1876,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 < self->extracted_dir_list->len; i++) {
+ GFile *file = g_array_index (self->extracted_dir_list, GFileAndInfo, i).file;
+ GFileInfo *info = g_array_index (self->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)) {
+ self->cancellable, NULL);
+ if (g_cancellable_is_cancelled (self->cancellable)) {
return;
}
}
}
static void
-autoar_extract_step_cleanup (AutoarExtract *arextract) {
+autoar_extractor_step_cleanup (AutoarExtractor *self) {
/* 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");
+ self->completed_size = self->size;
+ self->completed_files = self->files;
+ self->notify_last = 0;
+ autoar_extractor_signal_progress (self);
+ g_debug ("autoar_extractor_step_cleanup: Update progress");
- if (arextract->delete_after_extraction) {
- g_debug ("autoar_extract_step_cleanup: Delete");
- g_file_delete (arextract->source_file, arextract->cancellable, NULL);
+ if (self->delete_after_extraction) {
+ g_debug ("autoar_extractor_step_cleanup: Delete");
+ g_file_delete (self->source_file, self->cancellable, NULL);
}
}
static void
-autoar_extract_run (AutoarExtract *arextract)
+autoar_extractor_run (AutoarExtractor *self)
{
/* 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 (self));
- g_return_if_fail (arextract->source_file != NULL);
- g_return_if_fail (arextract->output_file != NULL);
+ g_return_if_fail (self->source_file != NULL);
+ g_return_if_fail (self->output_file != NULL);
- if (g_cancellable_is_cancelled (arextract->cancellable)) {
- autoar_extract_signal_cancelled (arextract);
+ if (g_cancellable_is_cancelled (self->cancellable)) {
+ autoar_extractor_signal_cancelled (self);
return;
}
i = 0;
- steps[i++] = autoar_extract_step_scan_toplevel;
- steps[i++] = autoar_extract_step_set_destination;
- steps[i++] = autoar_extract_step_decide_destination;
- 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_destination;
+ steps[i++] = autoar_extractor_step_decide_destination;
+ 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])(self);
+ g_debug ("autoar_extractor_run: Step %d End", i);
+ if (self->error != NULL) {
+ autoar_extractor_signal_error (self);
return;
}
- if (g_cancellable_is_cancelled (arextract->cancellable)) {
- autoar_extract_signal_cancelled (arextract);
+ if (g_cancellable_is_cancelled (self->cancellable)) {
+ autoar_extractor_signal_cancelled (self);
return;
}
}
- autoar_extract_signal_completed (arextract);
+ autoar_extractor_signal_completed (self);
}
/**
- * autoar_extract_start:
- * @arextract: an #AutoarExtract object
+ * autoar_extractor_start:
+ * @self: 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 *self,
+ GCancellable *cancellable)
{
if (cancellable != NULL)
g_object_ref (cancellable);
- arextract->cancellable = cancellable;
- arextract->in_thread = FALSE;
- autoar_extract_run (arextract);
+ self->cancellable = cancellable;
+ self->in_thread = FALSE;
+ autoar_extractor_run (self);
}
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 *self = source_object;
+ autoar_extractor_run (self);
g_task_return_pointer (task, NULL, g_free);
- g_object_unref (arextract);
+ g_object_unref (self);
g_object_unref (task);
}
/**
- * autoar_extract_start_async:
- * @arextract: an #AutoarExtract object
+ * autoar_extractor_start_async:
+ * @self: 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 *self,
+ GCancellable *cancellable)
{
GTask *task;
- g_object_ref (arextract);
+ g_object_ref (self);
if (cancellable != NULL)
g_object_ref (cancellable);
- arextract->cancellable = cancellable;
- arextract->in_thread = TRUE;
+ self->cancellable = cancellable;
+ self->in_thread = TRUE;
- task = g_task_new (arextract, NULL, NULL, NULL);
+ task = g_task_new (self, 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..e415a78
--- /dev/null
+++ b/gnome-autoar/autoar-extractor.h
@@ -0,0 +1,84 @@
+/* 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 *self,
+ GCancellable *cancellable);
+void autoar_extractor_start_async (AutoarExtractor *self,
+ GCancellable *cancellable);
+
+GFile *autoar_extractor_get_source_file (AutoarExtractor *self);
+GFile *autoar_extractor_get_output_file (AutoarExtractor *self);
+guint64 autoar_extractor_get_size (AutoarExtractor *self);
+guint64 autoar_extractor_get_completed_size (AutoarExtractor *self);
+guint autoar_extractor_get_files (AutoarExtractor *self);
+guint autoar_extractor_get_completed_files (AutoarExtractor *self);
+gboolean autoar_extractor_get_output_is_dest (AutoarExtractor *self);
+gboolean autoar_extractor_get_delete_after_extraction (AutoarExtractor *self);
+gint64 autoar_extractor_get_notify_interval (AutoarExtractor *self);
+
+void autoar_extractor_set_output_is_dest (AutoarExtractor *self,
+ gboolean output_is_dest);
+void autoar_extractor_set_delete_after_extraction (AutoarExtractor *self,
+ gboolean delete_if_succeed);
+void autoar_extractor_set_notify_interval (AutoarExtractor *self,
+ gint64 notify_interval);
+
+typedef enum {
+ AUTOAR_CONFLICT_SKIP = 0,
+ AUTOAR_CONFLICT_OVERWRITE,
+ AUTOAR_CONFLICT_CHANGE_DESTINATION
+} 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 1662320..ac2ec41 100644
--- a/tests/test-extract-unit.c
+++ b/tests/test-extract-unit.c
@@ -153,7 +153,7 @@ extract_test_free (ExtractTest *extract_test)
}
static void
-scanned_handler (AutoarExtract *arextract,
+scanned_handler (AutoarExtractor *extractor,
guint files,
gpointer user_data)
{
@@ -163,7 +163,7 @@ scanned_handler (AutoarExtract *arextract,
}
static GFile*
-decide_destination_handler (AutoarExtract *arextract,
+decide_destination_handler (AutoarExtractor *extractor,
GFile *dest,
GList *files,
gpointer user_data)
@@ -180,7 +180,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)
@@ -192,7 +192,7 @@ progress_handler (AutoarExtract *arextract,
}
static AutoarConflictAction
-conflict_handler (AutoarExtract *arextract,
+conflict_handler (AutoarExtractor *extractor,
GFile *file,
GFile **new_file,
gpointer user_data)
@@ -228,7 +228,7 @@ conflict_handler (AutoarExtract *arextract,
}
static void
-error_handler (AutoarExtract *arextract,
+error_handler (AutoarExtractor *extractor,
GError *error,
gpointer user_data)
{
@@ -238,7 +238,7 @@ error_handler (AutoarExtract *arextract,
}
static void
-completed_handler (AutoarExtract *arextract,
+completed_handler (AutoarExtractor *extractor,
gpointer user_data)
{
ExtractTestData *data = user_data;
@@ -247,7 +247,7 @@ completed_handler (AutoarExtract *arextract,
}
static void
-cancelled_handler (AutoarExtract *arextract,
+cancelled_handler (AutoarExtractor *extractor,
gpointer user_data)
{
ExtractTestData *data = user_data;
@@ -256,7 +256,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;
@@ -264,19 +264,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,
@@ -491,7 +491,7 @@ test_one_file_same_name (void)
g_autoptr (ExtractTest) extract_test = NULL;
g_autoptr (ExtractTestData) data = NULL;
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");
@@ -502,11 +502,11 @@ test_one_file_same_name (void)
archive = g_file_get_child (extract_test->input, "arextract.zip");
- arextract = autoar_extract_new (archive, extract_test->output);
+ extractor = autoar_extractor_new (archive, extract_test->output);
- 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);
@@ -533,7 +533,7 @@ test_one_file_different_name (void)
g_autoptr (ExtractTest) extract_test = NULL;
g_autoptr (ExtractTestData) data = NULL;
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");
@@ -544,11 +544,11 @@ test_one_file_different_name (void)
archive = g_file_get_child (extract_test->input, "arextract.zip");
- arextract = autoar_extract_new (archive, extract_test->output);
+ extractor = autoar_extractor_new (archive, extract_test->output);
- 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);
@@ -580,7 +580,7 @@ test_multiple_files_same_name (void)
g_autoptr (ExtractTest) extract_test = NULL;
g_autoptr (ExtractTestData) data = NULL;
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");
@@ -591,11 +591,11 @@ test_multiple_files_same_name (void)
archive = g_file_get_child (extract_test->input, "arextract.zip");
- arextract = autoar_extract_new (archive, extract_test->output);
+ extractor = autoar_extractor_new (archive, extract_test->output);
- 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);
@@ -630,7 +630,7 @@ test_multiple_files_different_name (void)
g_autoptr (ExtractTest) extract_test = NULL;
g_autoptr (ExtractTestData) data = NULL;
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");
@@ -641,11 +641,11 @@ test_multiple_files_different_name (void)
archive = g_file_get_child (extract_test->input, "arextract.zip");
- arextract = autoar_extract_new (archive, extract_test->output);
+ extractor = autoar_extractor_new (archive, extract_test->output);
- 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);
@@ -673,7 +673,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");
@@ -692,11 +692,11 @@ test_one_file_conflict_overwrite (void)
archive = g_file_get_child (extract_test->input, "arextract.zip");
- arextract = autoar_extract_new (archive, extract_test->output);
+ extractor = autoar_extractor_new (archive, extract_test->output);
- 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,
@@ -727,7 +727,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");
@@ -746,9 +746,9 @@ test_one_file_conflict_new_destination (void)
archive = g_file_get_child (extract_test->input, "arextract.zip");
- arextract = autoar_extract_new (archive, extract_test->output);
+ extractor = autoar_extractor_new (archive, extract_test->output);
- 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),
@@ -759,7 +759,7 @@ test_one_file_conflict_new_destination (void)
g_file_get_child (extract_test->output,
"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,
@@ -789,7 +789,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");
@@ -808,15 +808,15 @@ test_one_file_conflict_skip_file (void)
archive = g_file_get_child (extract_test->input, "arextract.zip");
- arextract = autoar_extract_new (archive, extract_test->output);
+ extractor = autoar_extractor_new (archive, extract_test->output);
- 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,
@@ -851,7 +851,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");
@@ -871,11 +871,11 @@ test_one_file_error_file_over_directory (void)
archive = g_file_get_child (extract_test->input, "arextract.zip");
- arextract = autoar_extract_new (archive, extract_test->output);
+ extractor = autoar_extractor_new (archive, extract_test->output);
- 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,
@@ -909,7 +909,7 @@ test_change_extract_destination (void)
g_autoptr (ExtractTest) extract_test = NULL;
g_autoptr (ExtractTestData) data = NULL;
g_autoptr (GFile) archive = NULL;
- g_autoptr (AutoarExtract) arextract = NULL;
+ g_autoptr (AutoarExtractor) extractor = NULL;
extract_test = extract_test_new ("test-change-extract-destination");
@@ -920,13 +920,13 @@ test_change_extract_destination (void)
archive = g_file_get_child (extract_test->input, "arextract.zip");
- arextract = autoar_extract_new (archive, extract_test->output);
+ extractor = autoar_extractor_new (archive, extract_test->output);
- 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->output,
"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 01c2d38..d13f06e 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,20 +104,20 @@ 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);
- autoar_extract_set_delete_after_extraction (arextract, TRUE);
+ autoar_extractor_set_delete_after_extraction (extractor, TRUE);
- 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]