Commit 5cb35344 authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

use a custom _g_file_has_prefix that works has expected.

This function simply operates on uris and always works as expected.
parent 7b760bfd
......@@ -2349,6 +2349,32 @@ _g_file_resolve_all_symlinks (GFile *file,
}
gboolean
_g_file_has_prefix (GFile *file,
GFile *prefix)
{
char *file_uri;
char *prefix_uri;
gboolean result;
file_uri = g_file_get_uri (file);
prefix_uri = g_file_get_uri (prefix);
if (! g_str_has_suffix (prefix_uri, "/")) {
char *tmp;
tmp = g_strconcat (prefix_uri, "/", NULL);
g_free (prefix_uri);
prefix_uri = tmp;
}
result = g_str_has_prefix (file_uri, prefix_uri);
g_free (prefix_uri);
g_free (file_uri);
return result;
}
GFile *
_g_file_append_prefix (GFile *file,
const char *prefix)
......
......@@ -265,6 +265,8 @@ int _g_file_cmp_modification_time (GFile *a,
goffset _g_file_get_size (GFile *info);
GFile * _g_file_resolve_all_symlinks (GFile *file,
GError **error);
gboolean _g_file_has_prefix (GFile *file,
GFile *prefix);
GFile * _g_file_append_prefix (GFile *file,
const char *prefix);
GFile * _g_file_append_path (GFile *file,
......
......@@ -1610,7 +1610,7 @@ get_nearest_entry_point (GFile *file)
for (scan = list; scan; scan = scan->next) {
GthFileData *entry_point = scan->data;
if (g_file_equal (file, entry_point->file) || g_file_has_prefix (file, entry_point->file))
if (g_file_equal (file, entry_point->file) || _g_file_has_prefix (file, entry_point->file))
entries = g_list_prepend (entries, g_file_get_uri (entry_point->file));
}
......@@ -1620,9 +1620,10 @@ get_nearest_entry_point (GFile *file)
min_diff = 0;
for (scan = entries; scan; scan = scan->next) {
char *entry_uri = scan->data;
int entry_len = strlen (entry_uri);
int entry_len;
int diff;
entry_len = strlen (entry_uri);
diff = abs (entry_len - file_uri_len);
if ((scan == entries) || (diff < min_diff)) {
min_diff = diff;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment