[Interest] QDir::entry(Info)List on macos

Olivier B. perso.olivier.barthelemy at gmail.com
Thu Nov 15 09:49:08 CET 2018


What is the encoding of your source file?
QString constructors interprets char* as if they are UTF-8. If the
source file is encoded in your local encoding, the QString created for
QFile constructor will have a wrong unicode storage of your wanted
filename, then will try to convert what it thinks is UTF into your
local encoding to pass the filename to the system calls. Maybe the mac
explorer can work around this and adjust the displayed name, but the
Filesystem interface of Qt can't because that puts forbidden
characters in the real name?
Le jeu. 15 nov. 2018 à 08:55, Manner Róbert <rmanni at gmail.com> a écrit :
>
> On 11/14/18 5:34 PM, Thiago Macieira wrote:
> > On Wednesday, 14 November 2018 01:34:17 PST Manner Róbert wrote:
> >> int main() {
> >>   qDebug() << QDir(".").entryList();
> > QCoreApplication missing. Try again with it.
> >
> Tried, without success, still does not display these files. Even tried
> with QDirIterator, that is also working the same (skipping these files).
>
> With further checking I noticed that the files are only not displaying
> if I do not create them with Qt. Eg I created with "touch filenamé". If
> I create the same file with QFile, that seems to be found by these dir
> lists. I know it sounds insane.
>
>
> Locale is utf8:
>
> > locale
> LANG="en_US.UTF-8"
> LC_COLLATE="en_US.UTF-8"
> LC_CTYPE="en_US.UTF-8"
> LC_MESSAGES="en_US.UTF-8"
> LC_MONETARY="en_US.UTF-8"
> LC_NUMERIC="en_US.UTF-8"
> LC_TIME="en_US.UTF-8"
> LC_ALL="en_US.UTF-8"
>
> The modified source code:
>
> > cat main.cpp
> #include <QDirIterator>
> #include <QDebug>
> #include <QFileInfoList>
> #include <QCoreApplication>
> #include <QFile>
>
> int main(int argc, char** argv) {
>   QFile file("éáőú");  // This file is visible in the list! But not any
> other I create with touch for example.
>   file.open(QFile::WriteOnly);
>   file.close();
>
>   QCoreApplication app(argc, argv);
>   QDirIterator iterator(".", QDir::Files, QDirIterator::Subdirectories);
>   while (iterator.hasNext())
>     {
>       qDebug() << "QDiriterator" << iterator.next();
>     }
>
>   qDebug() << QDir(".").entryList(QDir::System | QDir::AllEntries |
> QDir::Hidden);
>
>   qDebug() << QDir(".").entryInfoList(QDir::System | QDir::AllEntries |
> QDir::Hidden);
> }
>
> Thanks in advance for any idea.
>
> Robert
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest



More information about the Interest mailing list