Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the correct case of a path?

Tags:

c++

qt

I have a small but itching problem. How do I get the correct case for a Windows path in Qt?

Let's say i have a path c:\documents and settings\wolfgang\documents stored in a QString str and i want to know the correct case, here C:\Document and Settings\Wolfgang\Documents. QDir(str).absolutePath() doesn't get me the path with correct case.

Any suggestions, since I have no clue what else i could try?

Thank you for your time!

like image 350
WolfgangP Avatar asked Sep 05 '10 03:09

WolfgangP


1 Answers

There isn't a simple way to do this, but you can try doing a QDir.entryList, and then do a case insensitive search on the results. This will provide you with the correct filename. You'll then need to get the absolutePath for that result.

This should give you the preserved-case for the path/filename.

like image 50
ocodo Avatar answered Oct 23 '22 17:10

ocodo