mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 15:36:14 +01:00
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>
This commit is contained in:
parent
b3379557af
commit
9d852bc6f3
@ -355,6 +355,7 @@ g_content_type_guess (const gchar *filename,
|
|||||||
char *basename;
|
char *basename;
|
||||||
char *type;
|
char *type;
|
||||||
char *dot;
|
char *dot;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
type = NULL;
|
type = NULL;
|
||||||
|
|
||||||
@ -367,11 +368,21 @@ g_content_type_guess (const gchar *filename,
|
|||||||
|
|
||||||
if (filename)
|
if (filename)
|
||||||
{
|
{
|
||||||
basename = g_path_get_basename (filename);
|
i = strlen (filename);
|
||||||
dot = strrchr (basename, '.');
|
if (i > 0 && filename[i - 1] == G_DIR_SEPARATOR)
|
||||||
if (dot)
|
{
|
||||||
type = g_strdup (dot);
|
type = g_strdup ("inode/directory");
|
||||||
g_free (basename);
|
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)
|
if (type)
|
||||||
|
Loading…
Reference in New Issue
Block a user