В Чтв, 11/01/2007 в 12:12 +0100, Alexander Larsson пишет:

> Really, we should have a function in gnome vfs that you pass the
> current
> uri too so it correctly handles relative uris.

I though that gnome_vfs_uri_resolve_relative should do this kind of
things...
But after reading doc's for this function, i can't understand following
paragraph:
  Otherwise, depending on its precise syntax, it
  inherits some aspects of the parent URI, but the
  parents' fragment and query components are ignored.
Does it means, that '..' & '.' won't be expanded?

Or we could assume, that:
 1) ./path/to/smth - is valid
    ./../path/to/smth - is NOT valid (a simple test can find
        this case and forbid it)
 2) ../../../path/to/smth - is valid
    ../path/../to/smth - is NOT valid
    ./path/to/../smth - is NOT valid


> Changing the cwd like
> that is not threadsafe and quite ugly.

Yeah, I know it's ugly fix =)

Could nautilus_location_bar_get_location (...) look like this:

        gboolean utf8;
        const char *charset;
        char *user_location_escaped, *locale_path, *user_location, *best_uri;
        GnomeVFSURI *currentURI, *bestURI;

        user_location = gtk_editable_get_chars (GTK_EDITABLE
(bar->details->entry), 0, -1);
        g_strstrip (user_location);
        utf8 = vfs_get_filename_charset (&charset);

        /* TODO: strip spaces at the end */
        if (!utf8) {
                locale_path = g_convert (user_location, -1, charset, "UTF-8", 
NULL,
NULL, NULL);
                if (locale_path != NULL) {
                        user_location_escaped = gnome_vfs_escape_path_string 
(locale_path);
                        g_free (locale_path);
                } else {
                        return g_strdup(bar->details->last_location);
                }
        } else {
                user_location_escaped = gnomr_vfs_escape_path_string 
(user_location);
        }
        currentURI = gnome_vfs_uri_new (bar->details->last_location);
        bestURI = gnome_vfs_uri_resolve_relative (currentURI,
user_location_escaped);
        best_uri = g_strdup (gnome_vfs_uri_get_path (bestURI));

        gnome_vfs_uri_unref (currentURI);
        gnome_vfs_uri_unref (bestURI);
        g_free (user_location_escaped);
        g_free (user_location);
        return best_uri;

Or i'm missing something?

-- 
nautilus-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/nautilus-list

Reply via email to