![]() |
![]() |
![]() |
![]() |
guint | completed-files | Read |
guint64 | completed-size | Read |
gboolean | delete-after-extraction | Read / Write / Construct |
gint64 | notify-interval | Read / Write / Construct |
GFile * | output-file | Read / Write / Construct Only |
gboolean | output-is-dest | Read / Write / Construct |
GFile * | source-file | Read / Write / Construct Only |
guint | total-files | Read |
guint64 | total-size | Read |
#define | AUTOAR_TYPE_EXTRACTOR |
#define | AUTOAR_EXTRACTOR_ERROR |
enum | AutoarConflictAction |
AutoarExtractor |
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 with the same
name as the source archive without the extension, the file will be extracted
to the output directory. Otherwise the files will be extracted in a directory
having the same name as the source 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_extractor_set_output_is_dest()
.
AutoarExtractor will not attempt to solve any name conflicts. If the destination directory already exists, it will proceed normally. If the destination directory cannot be created, it will fail with an error. It is possible however to change the destination, when “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 AutoarExtractor. This is convenient for solving name conflicts and implementing specific logic based on the contents of the archive.
When AutoarExtractor stops all work, it will emit one of the three signals: “cancelled”, “error”, and “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.
GQuark
autoar_extractor_quark (void
);
Gets the AutoarExtractor Error Quark.
AutoarExtractor * autoar_extractor_new (GFile *source_file
,GFile *output_file
);
Create a new AutoarExtractor object.
void autoar_extractor_start (AutoarExtractor *self
,GCancellable *cancellable
);
Runs the archive extracting work. All callbacks will be called in the same thread as the caller of this functions.
self |
an AutoarExtractor object |
|
cancellable |
optional GCancellable object, or |
void autoar_extractor_start_async (AutoarExtractor *self
,GCancellable *cancellable
);
Asynchronously runs the archive extracting work. You should connect to “cancelled”, “error”, and “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.
self |
an AutoarExtractor object |
|
cancellable |
optional GCancellable object, or |
GFile *
autoar_extractor_get_source_file (AutoarExtractor *self
);
Gets the GFile object which represents the source archive that will be extracted for this object.
GFile *
autoar_extractor_get_output_file (AutoarExtractor *self
);
Gets the GFile object which represents the output directory of extracted file or directory, or the extracted file or directory itself if you set “output-is-dest” on the returned object.
guint64
autoar_extractor_get_total_size (AutoarExtractor *self
);
Gets the size in bytes will be written when the operation is completed.
guint64
autoar_extractor_get_completed_size (AutoarExtractor *self
);
Gets the size in bytes has been written to disk.
guint
autoar_extractor_get_total_files (AutoarExtractor *self
);
Gets the total number of files will be written when the operation is completed.
guint
autoar_extractor_get_completed_files (AutoarExtractor *self
);
Gets the number of files has been written to disk.
gboolean
autoar_extractor_get_output_is_dest (AutoarExtractor *self
);
gboolean
autoar_extractor_get_delete_after_extraction
(AutoarExtractor *self
);
Whether the source archive will be deleted after a successful extraction.
gint64
autoar_extractor_get_notify_interval (AutoarExtractor *self
);
void autoar_extractor_set_output_is_dest (AutoarExtractor *self
,gboolean output_is_dest
);
By default “output-is-dest” is set to FALSE
, which means
only one file or directory will be created in “output-file”.
The destination is internally determined by analyzing the contents of the
archive. If this is not wanted, “output-is-dest” can be set to
TRUE
, which will make “output-file” the destination for
extracted files. In any case, the destination will be notified via
“decide-destination”, when it is possible to set a new
destination.
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_extractor_start()
or
autoar_extractor_start_async()
.
void autoar_extractor_set_delete_after_extraction (AutoarExtractor *self
,gboolean delete_after_extraction
);
By default “delete-after-extraction” is set to FALSE
so the
source archive will not be automatically deleted if extraction succeeds.
self |
||
delete_after_extraction |
|
void autoar_extractor_set_notify_interval (AutoarExtractor *self
,gint64 notify_interval
);
Sets the minimal interval between emission of “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.
“completed-files”
property“completed-files” guint
Number of files has been written.
Owner: AutoarExtractor
Flags: Read
Default value: 0
“completed-size”
property“completed-size” guint64
Bytes written to disk.
Owner: AutoarExtractor
Flags: Read
Default value: 0
“delete-after-extraction”
property“delete-after-extraction” gboolean
Whether the source archive is deleted after a successful extraction.
Owner: AutoarExtractor
Flags: Read / Write / Construct
Default value: FALSE
“notify-interval”
property“notify-interval” gint64
Minimal time interval between progress signal.
Owner: AutoarExtractor
Flags: Read / Write / Construct
Allowed values: >= 0
Default value: 100000
“output-file”
property“output-file” GFile *
The #GFile of the directory where the files will be extracted.
Owner: AutoarExtractor
Flags: Read / Write / Construct Only
“output-is-dest”
property“output-is-dest” gboolean
Whether #AutoarExtractor:output-file is used as destination.
Owner: AutoarExtractor
Flags: Read / Write / Construct
Default value: FALSE
“source-file”
property“source-file” GFile *
The #GFile of the source archive that will be extracted.
Owner: AutoarExtractor
Flags: Read / Write / Construct Only
“total-files”
property“total-files” guint
Number of files in the archive.
Owner: AutoarExtractor
Flags: Read
Default value: 0
“total-size”
property“total-size” guint64
Total size of the extracted files.
Owner: AutoarExtractor
Flags: Read
Default value: 0
“cancelled”
signalvoid user_function (AutoarExtractor *self, gpointer user_data)
This signal is emitted after archive extracting job is cancelled by the GCancellable.
Flags: Run Last
“completed”
signalvoid user_function (AutoarExtractor *self, gpointer user_data)
This signal is emitted after the archive extracting job is successfully completed.
Flags: Run Last
“conflict”
signalguint user_function (AutoarExtractor *self, GFile *file, gpointer new_file, gpointer user_data)
self |
the AutoarExtractor |
|
file |
a GFile for the file that caused a conflict |
|
new_file |
a GFile for the new destination of |
|
user_data |
user data set when the signal handler was connected. |
the AutoarConflictAction to be performed by AutoarExtractor
This signal is used to report and offer the possibility to solve name
conflicts when extracting files. If it is not handled, the file
will be
skipped.
Flags: Run Last
“decide-destination”
signalGObject* user_function (AutoarExtractor *self, GFile *destination, gpointer files, gpointer user_data)
self |
the AutoarExtractor |
|
destination |
a GFile for the location where files will be extracted |
|
files |
the list of GFile objects to be extracted. All have |
|
user_data |
user data set when the signal handler was connected. |
GFile for location that will overwrite
destination
, or NULL
if this is not wanted
This signal is emitted when the path of the destination is determined. It is useful for solving name conflicts or for setting a new destination, based on the contents of the archive.
[transfer full]
Flags: Run Last
“error”
signalvoid user_function (AutoarExtractor *self, GError *error, gpointer user_data)
This signal is emitted when error occurs and all jobs should be terminated.
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.
self |
the AutoarExtractor |
|
error |
the GError |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
“progress”
signalvoid user_function (AutoarExtractor *self, guint64 completed_size, guint completed_files, gpointer user_data)
This signal is used to report progress of extraction.
self |
the AutoarExtractor |
|
completed_size |
bytes has been written to disk |
|
completed_files |
number of files have been written to disk |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
“request-passphrase”
signalchar* user_function (AutoarExtractor *self, gpointer user_data)
This signal is emitted when the archive extracting job needs a passphrase.
Flags: Run Last
“scanned”
signalvoid user_function (AutoarExtractor *self, guint files, gpointer user_data)
This signal is emitted when AutoarExtractor finish scanning filename entries in the source archive.
self |
the AutoarExtractor |
|
files |
the number of files will be extracted from the source archive |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last