[Interest] Handling of ~ paths
Scott Bloom
scott at towel42.com
Thu Jun 11 20:03:00 CEST 2020
I’m feeling really stupid right now 😊
Ive been a Qt user for almost 20 years, and I cant believe I have never had to deal with this before.
If you are working with a path, for use in QDir, QFileInfo, QFile etc etc, and the path string is using a ~, either of the form ~/foo.txt or ~user/foo.txt, Qt seems to be treating it as a relative path of the current user, and prepends “/home/scott” in my case to the path, and of course, the canonicalPath returns an empty string because that file path is invalid and doesn’t exist.
What is the Qt way to handle this? It cant be to tell your users not to use ~. Can it? Does everyone write their own little “analyze the string before actually using it, and handle ~”?
Thanks
Scott
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20200611/495c0809/attachment.html>
More information about the Interest
mailing list