Project

General

Profile

Exiv2 does not like square root symbol √ in a Windows folder name

Added by Rory Hill about 6 years ago

I am running the Exiv2 library in Windows 10, Qt 5.5. My program dies with the windows message "This application has requested the Runtime to terminate it in an unusual way."

When running in debug mode in Qt the message is "terminate called after throwing an instance of 'Exiv2::BasicError<char>'
what(): E:/2015/201507/2015-07-04_Moon Lake √/2015-07-04_0001.CR2: Failed to open the data source: No such file or directory (errno = 2)

The code that produced this:

QString fileName = "E:/2015/201507/2015-07-04_Moon Lake √/2015-07-04_0001.CR2";
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fileName.toStdString());

I can access this folder and open files within using the Qt QFile. I only encounter this problem with Exiv2.

I'm using minGW 4.9.2 32bit.

Any tips on how to avoid this other than renaming folders?

Thanks in advance
Rory


Replies (5)

RE: Exiv2 does not like square root symbol √ in a Windows folder name - Added by Robin Mills about 6 years ago

Rory

You're into uncharted waters. You're discussing non-ascii characters in MinGW. I'll confess that MinGW is my least favourite platform and I only support it because I love Qt. The obvious fix is to kill off the √ in the path name.

How does Exiv2 deal with non-ascii characters? It doesn't. It passes the responsibility to the C runtime library function fopen. He does this in this function: (src/basicio.cpp#1004):

    int FileIo::open(const std::string& mode)
    {
        close();
        p_->openMode_ = mode;
        p_->opMode_ = Impl::opSeek;
#ifdef EXV_UNICODE_PATH
        if (p_->wpMode_ == Impl::wpUnicode) {
            p_->fp_ = ::_wfopen(wpath().c_str(), s2ws(mode).c_str());
        }
        else
#endif
        {
            p_->fp_ = ::fopen(path().c_str(), mode.c_str());
        }
        if (!p_->fp_) return 1;
        return 0;
    }

You can see that you'll have to build Exiv2 with the EXV_UNICODE_PATH set to take the wide character path and use _wfopen. I know this works on Windows with the Microsoft Compiler. Does this work on MinGW? You're possibly the first person on planet earth to investigate this.

You can set that flag when you build from the command-line with:

$ make clean ; ./configure CXXFLAGS=-DEXV_UNICODE_PATH=1 ; make ; make install
If it doesn't work, don't give up. I have another couple of suggestions which involve the code-page and UTF-8. However we can discuss more complicated tricks if/when you are stuck.

It's a pouring wet day in England and I guess it's the same in BC. Puzzles like this give us something to do in this weather.

RE: Exiv2 does not like square root symbol √ in a Windows folder name - Added by Rory Hill about 6 years ago

Thanks Robin. It's raining here too. We're off to Tofino for a few days. I'll try re-installing Exiv2 late next week and report back then.

Cheers
Rory

RE: Exiv2 does not like square root symbol √ in a Windows folder name - Added by Robin Mills about 6 years ago

Enjoy your trip. When we lived in the States, we used to visit friends in Seattle for Thanksgiving. So I know all about your weather in the Pacific Northwest in November. We went to Friday Harbor once on Black Friday. Friday Harbor is close to Vancouver Island.

I've been messing and building stuff. There's more to fixing this than simply ./configure CXXFLAGS=-DEXV_UNICODE_PATH=1. There's an outstanding issue #851 concerning UNICODE support. I'll fix that and update this. http://dev.exiv2.org/issues/851

RE: Exiv2 does not like square root symbol √ in a Windows folder name - Added by Rory Hill about 6 years ago

That seems to have done the trick Robin. Thanks!

This is what the view was like from the house we rented in Tofino.

RE: Exiv2 does not like square root symbol √ in a Windows folder name - Added by Robin Mills about 6 years ago

Looks really beautiful. We haven't been in BC. We lived in the States for 14 years and visited all 50 States. We decided to avoid Canada and Mexico and to limit our travels to the USA. We retired in April 2014 and are undertaking a home remodel/renovation project on our house in England. We hope to finish in spring 2016. Next winter we're planning a trip around the world and will visit the non European members of Team Exiv2 in India, China, Vietnam, Malaysia, Singapore and Peru. We'll have Christmas with friends in Australia and visit NZ for the first time. So, I think our next trip "home" to the West Coast will be Fall 2017. http://clanmills.com/BucketList.shtml Incidentally, Alan Pater who works on our XMP support, is from BC and lives in Peru.

Very pleased to hear that your code's working. I revisited #851 and decided to "leave well alone". Converting all our sample applications to build and run in UNICODE would be quite an undertaking and nobody has asked for this to be done. Lots of other stuff to work on over the winter.

Nice sunny Sunday morning in England. Time to clear the leaves again (every other day in November). We'll get the patio finished this week.

    (1-5/5)