mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +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 *type;
|
||||
char *dot;
|
||||
size_t i;
|
||||
|
||||
type = NULL;
|
||||
|
||||
@ -366,6 +367,15 @@ g_content_type_guess (const gchar *filename,
|
||||
g_return_val_if_fail (data_size != (gsize) -1, g_strdup ("*"));
|
||||
|
||||
if (filename)
|
||||
{
|
||||
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, '.');
|
||||
@ -373,6 +383,7 @@ g_content_type_guess (const gchar *filename,
|
||||
type = g_strdup (dot);
|
||||
g_free (basename);
|
||||
}
|
||||
}
|
||||
|
||||
if (type)
|
||||
return type;
|
||||
|
Loading…
Reference in New Issue
Block a user