[Interest] Detecting subdirectories in QDir
Oleg Yadrov
oleg.yadrov at qt.io
Wed Jul 11 16:44:46 CEST 2018
Hi there,
You can compare their absolute paths.
#include <QCoreApplication>
#include <QDir>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
QDir a("/Users/olegyadrov/one/two/three");
QDir b("/Users/olegyadrov/one/two");
QDir c("/Users/olegyadrov/one/four");
qDebug() << a.absolutePath().startsWith(b.absolutePath());
qDebug() << a.absolutePath().startsWith(c.absolutePath());
return app.exec();
}
outputs
true
false
Best regards,
Oleg Yadrov - oleg.yadrov at qt.io<mailto:oleg.yadrov at qt.io>
On Jul 11, 2018, at 5:04 AM, Tom Isaacson via Interest <interest at qt-project.org<mailto:interest at qt-project.org>> wrote:
Is there any way of finding if one QDir is a subdirectory of another? So for instance:
C:\One\Two\Three
is a subdirectory of:
C:\One\Two
but not of:
C:\One\Four
Thanks.
Tom Isaacson
_______________________________________________
Interest mailing list
Interest at qt-project.org<mailto:Interest at qt-project.org>
http://lists.qt-project.org/mailman/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180711/4f6d8059/attachment.html>
More information about the Interest
mailing list