summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <philip@tecnocode.co.uk>2020-09-11 09:49:04 +0000
committerPhilip Withnall <philip@tecnocode.co.uk>2020-09-11 09:49:04 +0000
commitc3eda78adaa770ade8343404dd66e82b9c02c235 (patch)
treeb027f2e64f4170808f7c2907a76e5e70b1dd5729
parentb7c75f78ab7b2983ad91355af87f69fee9f44aa3 (diff)
parent9d859f001d8dbf87c479ba8528a2e60d0b5328b7 (diff)
downloadglib-c3eda78adaa770ade8343404dd66e82b9c02c235.tar.gz
Merge branch '2194-winhttp-file-display-name' into 'master'
gwinhttpfile: Set display-name attribute on file info Closes #2194 See merge request GNOME/glib!1644
-rw-r--r--gio/win32/gwinhttpfile.c24
-rw-r--r--glib/gutf8.c2
2 files changed, 25 insertions, 1 deletions
diff --git a/gio/win32/gwinhttpfile.c b/gio/win32/gwinhttpfile.c
index cf5eed31d..509cdeb33 100644
--- a/gio/win32/gwinhttpfile.c
+++ b/gio/win32/gwinhttpfile.c
@@ -29,6 +29,7 @@
#include "gio/gfile.h"
#include "gio/gfileattribute.h"
#include "gio/gfileinfo.h"
+#include "gio/gfileinfo-priv.h"
#include "gwinhttpfile.h"
#include "gwinhttpfileinputstream.h"
#include "gwinhttpfileoutputstream.h"
@@ -178,6 +179,21 @@ g_winhttp_file_get_basename (GFile *file)
}
static char *
+g_winhttp_file_get_display_name (GFile *file)
+{
+ char *basename;
+
+ /* FIXME: This could be improved by using a new g_utf16_make_valid() function
+ * to recover what we can from the URI, and then suffixing it with
+ * “ (invalid encoding)” as per g_filename_display_basename(). */
+ basename = g_winhttp_file_get_basename (file);
+ if (!basename)
+ return g_strdup (_(" (invalid encoding)"));
+
+ return g_steal_pointer (&basename);
+}
+
+static char *
g_winhttp_file_get_path (GFile *file)
{
return NULL;
@@ -513,6 +529,14 @@ g_winhttp_file_query_info (GFile *file,
g_file_info_set_name (info, basename);
g_free (basename);
+ if (_g_file_attribute_matcher_matches_id (matcher,
+ G_FILE_ATTRIBUTE_ID_STANDARD_DISPLAY_NAME))
+ {
+ char *display_name = g_winhttp_file_get_display_name (file);
+ g_file_info_set_display_name (info, display_name);
+ g_free (display_name);
+ }
+
content_length = NULL;
if (_g_winhttp_query_header (winhttp_file->vfs,
request,
diff --git a/glib/gutf8.c b/glib/gutf8.c
index bcb4f56bc..51ad0d09b 100644
--- a/glib/gutf8.c
+++ b/glib/gutf8.c
@@ -1006,7 +1006,7 @@ g_ucs4_to_utf8 (const gunichar *str,
* string; it may e.g. include embedded NUL characters. The only
* validation done by this function is to ensure that the input can
* be correctly interpreted as UTF-16, i.e. it doesn't contain
- * things unpaired surrogates.
+ * unpaired surrogates or partial character sequences.
*
* Returns: (transfer full): a pointer to a newly allocated UTF-8 string.
* This value must be freed with g_free(). If an error occurs,