[glib: 3/11] gio: implement simple directory type detection
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 3/11] gio: implement simple directory type detection
- Date: Thu, 17 Mar 2022 15:14:17 +0000 (UTC)
commit 9d852bc6f3e5f93c137d372eead997cb0d81f608
Author: Marc-André Lureau <marcandre lureau redhat com>
Date: Wed Feb 16 15:13:03 2022 +0400
gio: implement simple directory type detection
Use a logic similar to what is done for Unix, based on trailing path
separator.
Signed-off-by: Marc-André Lureau <marcandre lureau redhat com>
gio/gcontenttype-win32.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/gio/gcontenttype-win32.c b/gio/gcontenttype-win32.c
index 2f3b0da7e..cac114e56 100644
--- a/gio/gcontenttype-win32.c
+++ b/gio/gcontenttype-win32.c
@@ -355,6 +355,7 @@ g_content_type_guess (const gchar *filename,
char *basename;
char *type;
char *dot;
+ size_t i;
type = NULL;
@@ -367,11 +368,21 @@ g_content_type_guess (const gchar *filename,
if (filename)
{
- basename = g_path_get_basename (filename);
- dot = strrchr (basename, '.');
- if (dot)
- type = g_strdup (dot);
- g_free (basename);
+ i = strlen (filename);
+ if (i > 0 && filename[i - 1] == G_DIR_SEPARATOR)
+ {
+ type = g_strdup ("inode/directory");
+ if (result_uncertain)
+ *result_uncertain = TRUE;
+ }
+ else
+ {
+ basename = g_path_get_basename (filename);
+ dot = strrchr (basename, '.');
+ if (dot)
+ type = g_strdup (dot);
+ g_free (basename);
+ }
}
if (type)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]