Inconsistency in Uri::append_file_name() and Uri::uri_exists()?



Hi,

I think I have found a bug in Uri::append_file_name() when used together with Uri::uri_exists(), but maybe I am just missing something. The problem is this: If you pass a filename (of an existing file) to this function which contains special characters, the filename which is appended will be escaped. After escaping the string, calling uri_exists() on the resulting uri will return 'false'.

I noticed this happen in a wrapper function I wrote (I have put in some test output):

--------------------- 8< -----------------------------------------------

    /// Appends @c filename to the current URI, taking care of escaping
    /// special characters in the file name and inserting directory
    /// separators.
    /// @return The new URI as a string.
    Glib::ustring append_filename(const Glib::ustring& filename) {
        std::cout << "appending: " << filename << " to ";
        std::cout << uri_->to_string() << std::endl;
        UriPtr uri = uri_->append_file_name(filename);
        std::cout << "Result: " << uri->to_string() << std::endl;
        assert (uri->uri_exists());
        *this = File();
        return get_uri();
    }

--------------------- 8< -----------------------------------------------

The test output for an example file on my filesystem yields this:

appending: täst to file:///home/matthias
Result: file:///home/matthias/t%C3%A4st
Duality.elf: ../src/dfm-file.hpp:240: Glib::ustring File::append_filename(const Glib::ustring&): Assertion `uri->uri_exists()' failed.

It looks as if either append_file_name() or uri_exists() screws up on escaped paths. Or maybe I am missing something? Would be nice if you could try this yourself with a test setup and tell me if you experience the same problems.

Best regards,
Matthias Kaeppler




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