[gcab] trivial: Split up the code creating a GInputStream for a GCabFile
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcab] trivial: Split up the code creating a GInputStream for a GCabFile
- Date: Fri, 15 Dec 2017 15:42:56 +0000 (UTC)
commit c15a22781ef74cb226b7d09055015742ec96f5c4
Author: Richard Hughes <richard hughsie com>
Date: Fri Dec 15 10:33:43 2017 +0000
trivial: Split up the code creating a GInputStream for a GCabFile
libgcab/gcab-cabinet.c | 9 +--------
libgcab/gcab-file.c | 13 +++++++++++++
libgcab/gcab-priv.h | 3 +++
3 files changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/libgcab/gcab-cabinet.c b/libgcab/gcab-cabinet.c
index e4cea35..f86c5bb 100644
--- a/libgcab/gcab-cabinet.c
+++ b/libgcab/gcab-cabinet.c
@@ -295,14 +295,7 @@ gcab_cabinet_write (GCabCabinet *self,
if (file_callback)
file_callback (file, user_data);
- GFile *gfile = gcab_file_get_gfile (file);
- if (gfile == NULL) {
- g_set_error (error, GCAB_ERROR, GCAB_ERROR_FORMAT,
- "No GFile for %s", gcab_file_get_name (file));
- return FALSE;
- }
-
- in = G_INPUT_STREAM (g_file_read (gfile, cancellable, error));
+ in = gcab_file_get_input_stream (file, cancellable, error);
if (in == NULL)
return FALSE;
diff --git a/libgcab/gcab-file.c b/libgcab/gcab-file.c
index 6ea46f2..ee8adb4 100644
--- a/libgcab/gcab-file.c
+++ b/libgcab/gcab-file.c
@@ -376,6 +376,19 @@ gcab_file_new_steal_cfile (cfile_t **cfile)
return file;
}
+G_GNUC_INTERNAL GInputStream *
+gcab_file_get_input_stream (GCabFile *self, GCancellable *cancellable, GError **error)
+{
+ /* backed by a GFile */
+ if (self->file != NULL)
+ return G_INPUT_STREAM (g_file_read (self->file, cancellable, error));
+
+ /* nothing to do */
+ g_set_error (error, GCAB_ERROR, GCAB_ERROR_FORMAT,
+ "No GFile for %s", gcab_file_get_name (self));
+ return NULL;
+}
+
/**
* gcab_file_get_extract_name:
* @file: a #GCabFile
diff --git a/libgcab/gcab-priv.h b/libgcab/gcab-priv.h
index 4d930ed..a4efab6 100644
--- a/libgcab/gcab-priv.h
+++ b/libgcab/gcab-priv.h
@@ -61,5 +61,8 @@ gboolean gcab_folder_extract (GCabFolder *self,
gpointer callback_data,
GCancellable *cancellable,
GError **error);
+GInputStream *gcab_file_get_input_stream (GCabFile *file,
+ GCancellable *cancellable,
+ GError **error);
#endif /* GCAB_PRIV_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]