mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 11:41:09 +00:00
gstutils: Add g_util_filename_compare
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4491>
This commit is contained in:
parent
0a292b8246
commit
fa4b46680d
2 changed files with 39 additions and 0 deletions
|
@ -4801,3 +4801,39 @@ gst_type_is_plugin_api (GType type, GstPluginAPIFlags * flags)
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_util_filename_compare:
|
||||
* @a: a filename to compare with @b
|
||||
* @b: a filename to compare with @a
|
||||
*
|
||||
* Compares the given filenames using natural ordering.
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
gint
|
||||
gst_util_filename_compare (const gchar * a, const gchar * b)
|
||||
{
|
||||
gchar *a_utf8, *b_utf8;
|
||||
gchar *a1, *b1;
|
||||
gint ret;
|
||||
|
||||
/* Filenames in GLib are only guaranteed to be UTF-8 on Windows */
|
||||
a_utf8 = g_filename_to_utf8 ((gchar *) a, -1, NULL, NULL, NULL);
|
||||
b_utf8 = g_filename_to_utf8 ((gchar *) b, -1, NULL, NULL, NULL);
|
||||
|
||||
if (a_utf8 == NULL || b_utf8 == NULL) {
|
||||
return strcmp (a, b);
|
||||
}
|
||||
|
||||
a1 = g_utf8_collate_key_for_filename (a_utf8, -1);
|
||||
b1 = g_utf8_collate_key_for_filename (b_utf8, -1);
|
||||
ret = strcmp (a1, b1);
|
||||
g_free (a1);
|
||||
g_free (b1);
|
||||
|
||||
g_free (a_utf8);
|
||||
g_free (b_utf8);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -1243,6 +1243,9 @@ gboolean gst_type_is_plugin_api (GType type, GstPluginAPIFlags *
|
|||
GST_API
|
||||
guint gst_util_ceil_log2 (guint32 v);
|
||||
|
||||
GST_API
|
||||
gint gst_util_filename_compare (const gchar *a, const gchar *b);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_UTILS_H__ */
|
||||
|
|
Loading…
Reference in a new issue