-static gchar *
-reduce_path (const gchar *dirname)
-{
- gchar **parts;
- gchar *part;
- GList *list, *tmp;
- GString *result;
- gchar *res;
- gint i;
-
- parts = g_strsplit (dirname, G_DIR_SEPARATOR_S, 0);
- list = NULL;
- for (i = 0; (part = parts [i]) != NULL; i++) {
- if (!strcmp (part, "."))
- continue;
-
- if (!strcmp (part, "..")) {
- if (list && list->next) /* Don't remove root */
- list = g_list_delete_link (list, list);
- } else {
- list = g_list_prepend (list, part);
- }
- }
-
- result = g_string_new ("");
- list = g_list_reverse (list);
-
- for (tmp = list; tmp; tmp = tmp->next) {
- gchar *data = (gchar *) tmp->data;
-
- if (data && *data) {
-#ifdef PLATFORM_WIN32
- if (result->len == 0)
- g_string_append_printf (result, "%s\\", data);
- else if (result->str [result->len - 1] == '\\')
- g_string_append_printf (result, "%s", data);
- else
-#endif
- g_string_append_printf (result, "%c%s",
- G_DIR_SEPARATOR, data);
- }
- }
-
- res = result->str;
- g_string_free (result, FALSE);
- g_list_free (list);
- g_strfreev (parts);
- return res;
-}
-