[gimp] app: remove obsolete cruft from file-utils.[ch]
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: remove obsolete cruft from file-utils.[ch]
- Date: Mon, 7 Jul 2014 23:45:40 +0000 (UTC)
commit a43730390c3fe7681abcec10e282bb9b06f68b80
Author: Michael Natterer <mitch gimp org>
Date: Tue Jul 8 01:42:44 2014 +0200
app: remove obsolete cruft from file-utils.[ch]
app/file/file-utils.c | 250 -------------------------------------------------
app/file/file-utils.h | 7 --
2 files changed, 0 insertions(+), 257 deletions(-)
---
diff --git a/app/file/file-utils.c b/app/file/file-utils.c
index da90b55..d43b3fd 100644
--- a/app/file/file-utils.c
+++ b/app/file/file-utils.c
@@ -43,12 +43,6 @@
#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);
-
-
gboolean
file_utils_filename_is_uri (const gchar *filename,
GError **error)
@@ -167,53 +161,6 @@ file_utils_filename_to_uri (Gimp *gimp,
return uri;
}
-/**
- * file_utils_filename_from_uri:
- * @uri: a URI
- *
- * A utility function to be used as a replacement for
- * g_filename_from_uri(). It deals with file: URIs with hostname in a
- * platform-specific way. On Win32, a UNC path is created and
- * returned, on other platforms the URI is detected as non-local and
- * NULL is returned.
- *
- * Returns: newly allocated filename or %NULL if @uri is a remote file
- **/
-gchar *
-file_utils_filename_from_uri (const gchar *uri)
-{
- gchar *filename;
- gchar *hostname;
-
- g_return_val_if_fail (uri != NULL, NULL);
-
- filename = g_filename_from_uri (uri, &hostname, NULL);
-
- if (!filename)
- return NULL;
-
- if (hostname)
- {
- /* we have a file: URI with a hostname */
-#ifdef G_OS_WIN32
- /* on Win32, create a valid UNC path and use it as the filename */
-
- gchar *tmp = g_build_filename ("//", hostname, filename, NULL);
-
- g_free (filename);
- filename = tmp;
-#else
- /* otherwise return NULL, caller should use URI then */
- g_free (filename);
- filename = NULL;
-#endif
-
- g_free (hostname);
- }
-
- return filename;
-}
-
GFile *
file_utils_file_with_new_ext (GFile *file,
GFile *ext_file)
@@ -285,122 +232,6 @@ file_utils_uri_get_ext (const gchar *uri)
return ext;
}
-gchar *
-file_utils_uri_to_utf8_filename (const gchar *uri)
-{
- g_return_val_if_fail (uri != NULL, NULL);
-
- if (g_str_has_prefix (uri, "file:"))
- {
- gchar *filename = file_utils_filename_from_uri (uri);
-
- if (filename)
- {
- GError *error = NULL;
- gchar *utf8;
-
- utf8 = g_filename_to_utf8 (filename, -1, NULL, NULL, &error);
- g_free (filename);
-
- if (utf8)
- return utf8;
-
- g_warning ("%s: cannot convert filename to UTF-8: %s",
- G_STRLOC, error->message);
- g_error_free (error);
- }
- }
-
- return g_strdup (uri);
-}
-
-static gchar *
-file_utils_uri_to_utf8_basename (const gchar *uri)
-{
- gchar *filename;
- gchar *basename = NULL;
-
- g_return_val_if_fail (uri != NULL, NULL);
-
- filename = file_utils_uri_to_utf8_filename (uri);
-
- if (strstr (filename, G_DIR_SEPARATOR_S))
- {
- basename = g_path_get_basename (filename);
- }
- else if (strstr (filename, "://"))
- {
- basename = strrchr (uri, '/');
-
- if (basename)
- basename = g_strdup (basename + 1);
- }
-
- if (basename)
- {
- g_free (filename);
- return basename;
- }
-
- return filename;
-}
-
-gchar *
-file_utils_uri_display_basename (const gchar *uri)
-{
- gchar *basename = NULL;
-
- g_return_val_if_fail (uri != NULL, NULL);
-
- if (g_str_has_prefix (uri, "file:"))
- {
- gchar *filename = file_utils_filename_from_uri (uri);
-
- if (filename)
- {
- basename = g_filename_display_basename (filename);
- g_free (filename);
- }
- }
- else
- {
- gchar *name = file_utils_uri_display_name (uri);
-
- basename = strrchr (name, '/');
- if (basename)
- basename = g_strdup (basename + 1);
-
- g_free (name);
- }
-
- return basename ? basename : file_utils_uri_to_utf8_basename (uri);
-}
-
-gchar *
-file_utils_uri_display_name (const gchar *uri)
-{
- gchar *name = NULL;
-
- g_return_val_if_fail (uri != NULL, NULL);
-
- if (g_str_has_prefix (uri, "file:"))
- {
- gchar *filename = file_utils_filename_from_uri (uri);
-
- if (filename)
- {
- name = g_filename_display_name (filename);
- g_free (filename);
- }
- }
- else
- {
- name = file_utils_unescape_uri (uri, -1, "/", FALSE);
- }
-
- return name ? name : g_strdup (uri);
-}
-
GdkPixbuf *
file_utils_load_thumbnail (const gchar *filename)
{
@@ -481,84 +312,3 @@ file_utils_save_thumbnail (GimpImage *image,
return success;
}
-
-
-/* the following two functions are copied from glib/gconvert.c */
-
-static gint
-unescape_character (const gchar *scanner)
-{
- gint first_digit;
- gint second_digit;
-
- first_digit = g_ascii_xdigit_value (scanner[0]);
- if (first_digit < 0)
- return -1;
-
- second_digit = g_ascii_xdigit_value (scanner[1]);
- if (second_digit < 0)
- return -1;
-
- return (first_digit << 4) | second_digit;
-}
-
-static gchar *
-file_utils_unescape_uri (const gchar *escaped,
- gint len,
- const gchar *illegal_escaped_characters,
- gboolean ascii_must_not_be_escaped)
-{
- const gchar *in, *in_end;
- gchar *out, *result;
- gint c;
-
- if (escaped == NULL)
- return NULL;
-
- if (len < 0)
- len = strlen (escaped);
-
- result = g_malloc (len + 1);
-
- out = result;
- for (in = escaped, in_end = escaped + len; in < in_end; in++)
- {
- c = *in;
-
- if (c == '%')
- {
- /* catch partial escape sequences past the end of the substring */
- if (in + 3 > in_end)
- break;
-
- c = unescape_character (in + 1);
-
- /* catch bad escape sequences and NUL characters */
- if (c <= 0)
- break;
-
- /* catch escaped ASCII */
- if (ascii_must_not_be_escaped && c <= 0x7F)
- break;
-
- /* catch other illegal escaped characters */
- if (strchr (illegal_escaped_characters, c) != NULL)
- break;
-
- in += 2;
- }
-
- *out++ = c;
- }
-
- g_assert (out - result <= len);
- *out = '\0';
-
- if (in != in_end)
- {
- g_free (result);
- return NULL;
- }
-
- return result;
-}
diff --git a/app/file/file-utils.h b/app/file/file-utils.h
index b501c09..cc98c1e 100644
--- a/app/file/file-utils.h
+++ b/app/file/file-utils.h
@@ -26,17 +26,10 @@ gboolean file_utils_filename_is_uri (const gchar *filename,
gchar * file_utils_filename_to_uri (Gimp *gimp,
const gchar *filename,
GError **error);
-gchar * file_utils_filename_from_uri (const gchar *uri);
-gchar * file_utils_filename_from_file (GFile *file);
GFile * file_utils_file_with_new_ext (GFile *file,
GFile *ext_file);
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]