[gimp/gimp-2-8] app: fix saving/loading of .xcf.gz and other compressed XCFs
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-8] app: fix saving/loading of .xcf.gz and other compressed XCFs
- Date: Thu, 2 May 2013 18:19:56 +0000 (UTC)
commit a8aef360b9cb7ea0e32deed57d0bba01fe6fc0b2
Author: Michael Natterer <mitch gimp org>
Date: Thu May 2 20:05:35 2013 +0200
app: fix saving/loading of .xcf.gz and other compressed XCFs
Make file_utils_uri_get_ext() public and use it instead of
strrchr(uri, '.'). Also add "xz" to the list of matched special cases,
and some cleanup.
(partial cherry pick from commit e99c0045a2ad01d9712d588ea0aa1995791c67a7)
app/file/file-procedure.c | 14 ++++++++------
app/file/file-utils.c | 22 ++++++++++------------
app/file/file-utils.h | 41 +++++++++++++++++++++--------------------
3 files changed, 39 insertions(+), 38 deletions(-)
---
diff --git a/app/file/file-procedure.c b/app/file/file-procedure.c
index 24ed71d..13b6d17 100644
--- a/app/file/file-procedure.c
+++ b/app/file/file-procedure.c
@@ -290,16 +290,21 @@ file_proc_find_by_extension (GSList *procs,
GSList *p;
const gchar *ext;
- ext = strrchr (uri, '.');
+ ext = file_utils_uri_get_ext (uri);
- if (ext)
- ext++;
+ if (! (ext && *ext == '.'))
+ return NULL;
+
+ ext++;
for (p = procs; p; p = g_slist_next (p))
{
GimpPlugInProcedure *proc = p->data;
GSList *extensions;
+ if (skip_magic && proc->magics_list)
+ continue;
+
for (extensions = proc->extensions_list;
ext && extensions;
extensions = g_slist_next (extensions))
@@ -307,9 +312,6 @@ file_proc_find_by_extension (GSList *procs,
const gchar *p1 = ext;
const gchar *p2 = extensions->data;
- if (skip_magic && proc->magics_list)
- continue;
-
while (*p1 && *p2)
{
if (g_ascii_tolower (*p1) != g_ascii_tolower (*p2))
diff --git a/app/file/file-utils.c b/app/file/file-utils.c
index a50fec5..32b3f5f 100644
--- a/app/file/file-utils.c
+++ b/app/file/file-utils.c
@@ -43,12 +43,10 @@
#include "gimp-intl.h"
-static gchar * file_utils_unescape_uri (const gchar *escaped,
- gint len,
- const gchar *illegal_escaped_characters,
- gboolean ascii_must_not_be_escaped);
-static const gchar *file_utils_get_ext_start (const gchar *uri);
-
+static gchar * file_utils_unescape_uri (const gchar *escaped,
+ gint len,
+ const gchar *illegal_escaped_characters,
+ gboolean ascii_must_not_be_escaped);
gboolean
@@ -237,8 +235,8 @@ gchar *
file_utils_uri_with_new_ext (const gchar *uri,
const gchar *ext_uri)
{
- const gchar *uri_ext = file_utils_get_ext_start (uri);
- const gchar *ext_uri_ext = ext_uri ? file_utils_get_ext_start (ext_uri) : NULL;
+ const gchar *uri_ext = file_utils_uri_get_ext (uri);
+ const gchar *ext_uri_ext = ext_uri ? file_utils_uri_get_ext (ext_uri) : NULL;
gchar *uri_without_ext = g_strndup (uri, uri_ext - uri);
gchar *ret = g_strconcat (uri_without_ext, ext_uri_ext, NULL);
g_free (uri_without_ext);
@@ -247,17 +245,17 @@ file_utils_uri_with_new_ext (const gchar *uri,
/**
- * file_utils_get_ext_start:
+ * file_utils_uri_get_ext:
* @uri:
*
- * Returns the position of the extension (after the .) for an URI. If
+ * Returns the position of the extension (including the .) for an URI. If
* there is no extension the returned position is right after the
* string, at the terminating NULL character.
*
* Returns:
**/
-static const gchar *
-file_utils_get_ext_start (const gchar *uri)
+const gchar *
+file_utils_uri_get_ext (const gchar *uri)
{
const gchar *ext = NULL;
int uri_len = strlen (uri);
diff --git a/app/file/file-utils.h b/app/file/file-utils.h
index 3ecd6f8..c2ef7fc 100644
--- a/app/file/file-utils.h
+++ b/app/file/file-utils.h
@@ -24,26 +24,27 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
-gboolean file_utils_filename_is_uri (const gchar *filename,
- GError **error);
-gchar * file_utils_filename_to_uri (Gimp *gimp,
- const gchar *filename,
- GError **error);
-gchar * file_utils_any_to_uri (Gimp *gimp,
- const gchar *filename_or_uri,
- GError **error);
-gchar * file_utils_filename_from_uri (const gchar *uri);
-gchar * file_utils_uri_with_new_ext (const gchar *uri,
- const gchar *uri_with_ext);
-
-gchar * file_utils_uri_to_utf8_filename (const gchar *uri);
-
-gchar * file_utils_uri_display_basename (const gchar *uri);
-gchar * file_utils_uri_display_name (const gchar *uri);
-
-GdkPixbuf * file_utils_load_thumbnail (const gchar *filename);
-gboolean file_utils_save_thumbnail (GimpImage *image,
- const gchar *filename);
+gboolean file_utils_filename_is_uri (const gchar *filename,
+ GError **error);
+gchar * file_utils_filename_to_uri (Gimp *gimp,
+ const gchar *filename,
+ GError **error);
+gchar * file_utils_any_to_uri (Gimp *gimp,
+ const gchar *filename_or_uri,
+ GError **error);
+gchar * file_utils_filename_from_uri (const gchar *uri);
+gchar * file_utils_uri_with_new_ext (const gchar *uri,
+ const gchar *uri_with_ext);
+const gchar * file_utils_uri_get_ext (const gchar *uri);
+
+gchar * file_utils_uri_to_utf8_filename (const gchar *uri);
+
+gchar * file_utils_uri_display_basename (const gchar *uri);
+gchar * file_utils_uri_display_name (const gchar *uri);
+
+GdkPixbuf * file_utils_load_thumbnail (const gchar *filename);
+gboolean file_utils_save_thumbnail (GimpImage *image,
+ const gchar *filename);
#endif /* __FILE_UTILS_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]