[gcab] file: allow to set a different extract name
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcab] file: allow to set a different extract name
- Date: Fri, 18 Jan 2013 00:04:07 +0000 (UTC)
commit b59aa5bd34534fe12a14f20c848177d0ea5b2268
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date: Fri Jan 18 01:02:27 2013 +0100
file: allow to set a different extract name
libgcab/gcab-file.c | 18 ++++++++++++++++++
libgcab/gcab-file.h | 2 ++
libgcab/gcab-folder.c | 4 ++--
libgcab/gcab-priv.h | 1 +
4 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/libgcab/gcab-file.c b/libgcab/gcab-file.c
index 8b652cc..fba7836 100644
--- a/libgcab/gcab-file.c
+++ b/libgcab/gcab-file.c
@@ -27,6 +27,7 @@ gcab_file_finalize (GObject *object)
g_object_unref (self->file);
g_free (self->name);
+ g_free (self->extract_name);
G_OBJECT_CLASS (gcab_file_parent_class)->finalize (object);
}
@@ -201,3 +202,20 @@ gcab_file_new_with_cfile (const cfile_t *cfile)
return file;
}
+
+const gchar *
+gcab_file_get_extract_name (GCabFile *self)
+{
+ g_return_val_if_fail (GCAB_IS_FILE (self), NULL);
+
+ return self->extract_name ? self->extract_name : self->name;
+}
+
+void
+gcab_file_set_extract_name (GCabFile *self, const gchar *name)
+{
+ g_return_if_fail (GCAB_IS_FILE (self));
+
+ g_free (self->extract_name);
+ self->extract_name = g_strdup (name);
+}
diff --git a/libgcab/gcab-file.h b/libgcab/gcab-file.h
index c92ef82..e421de2 100644
--- a/libgcab/gcab-file.h
+++ b/libgcab/gcab-file.h
@@ -42,6 +42,8 @@ GType gcab_file_get_type (void) G_GNUC_CONST;
GCabFile * gcab_file_new_with_file (const gchar *name, GFile *file);
GFile * gcab_file_get_file (GCabFile *file);
const gchar * gcab_file_get_name (GCabFile *file);
+const gchar * gcab_file_get_extract_name (GCabFile *file);
+void gcab_file_set_extract_name (GCabFile *file, const gchar *name);
G_END_DECLS
diff --git a/libgcab/gcab-folder.c b/libgcab/gcab-folder.c
index b642557..f9c7f0f 100644
--- a/libgcab/gcab-folder.c
+++ b/libgcab/gcab-folder.c
@@ -316,8 +316,8 @@ gcab_folder_extract (GCabFolder *self,
if (file_callback && !file_callback (file, callback_data))
continue;
- int i = 0, len = strlen (file->name);
- gchar *fname = g_strdup (file->name);
+ gchar *fname = g_strdup (gcab_file_get_extract_name (file));
+ int i = 0, len = strlen (fname);
for (i = 0; i < len; i++)
if (fname[i] == '\\')
fname[i] = '/';
diff --git a/libgcab/gcab-priv.h b/libgcab/gcab-priv.h
index 82ce81f..3a1810f 100644
--- a/libgcab/gcab-priv.h
+++ b/libgcab/gcab-priv.h
@@ -15,6 +15,7 @@ struct _GCabFile
GObject parent_instance;
gchar *name;
+ gchar *extract_name;
GFile *file;
cfile_t cfile;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]