Can someone please comment on this short program



Hi,

since my question about Uri::append_file_name remained unanswered, I have set up a small test program which illustrates the problem. I still haven't found the error, and it would be nice if you could comment about why the output from this program is as it is (please assume that a file by the name "täst" exists in my home directory):

#include <iostream>
#include <libgnomevfsmm/uri.h>
#include <libgnomevfsmm/init.h>
#include <libgnomevfsmm/utils.h>

int main(int argc, char** argv)
{
    using namespace Gnome::Vfs;
    typedef Glib::RefPtr<Uri> UriPtr;
    init();
    std::string home_dir = Glib::getenv("HOME");
    Glib::ustring filename = "täst";

    { // Test 1
	UriPtr uri = Uri::create(get_uri_from_local_path(home_dir));
	std::cout << "Uri: " << uri->to_string() << " | exists: ";
	std::cout << std::boolalpha << uri->uri_exists() << std::endl;
    }

    { // Test 2
	UriPtr uri = Uri::create(get_uri_from_local_path(home_dir));
	uri = uri->append_file_name(filename);
	std::cout << "Uri: " << uri->to_string() << " | exists: ";
	std::cout << std::boolalpha << uri->uri_exists() << std::endl;
    }

    { // Test 3
	UriPtr uri = Uri::create(get_uri_from_local_path(home_dir));
	uri = uri->append_file_name(escape_string(filename));
	std::cout << "Uri: " << uri->to_string() << " | exists: ";
	std::cout << std::boolalpha << uri->uri_exists() << std::endl;
    }

}

Output:
Uri: file:///home/matthias | exists: true
Uri: file:///home/matthias/t%E4st | exists: false
Uri: file:///home/matthias/t%25E4st | exists: false

As soon as I append a filename which contains more than the initial 127 ASCII characters, the Uri object never seems to point to an existing entity (even if the file is there!). Furthermore, why do both outputs where the filename is appended differ in their "escapedness"? Will the already escaped filename which is passes to append_file_name() be escaped again (that is, the '%' symbol?).

I haven't yet found a way to make an Uri work when pointing to a file which name contains umlauts, please help.

Thanks,
Matthias




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]