Re: [Interest] Detecting subdirectories in QDir

2018-07-12 Thread Mårten Nordheim
Does it work properly if 'b' is root? On 11.07.2018 17:59, Oleg Yadrov wrote: Ha. I hope I didn't screw up this time. #include #include #include //returnstrueif'a'isasubdirectoryof'b' boolisSubdirectory(QDira,QDirb) { while(!a.isRoot()){ if(a.absolutePath()==b.absolutePath()) returntru

Re: [Interest] Detecting subdirectories in QDir

2018-07-11 Thread Thiago Macieira
On Wednesday, 11 July 2018 07:59:28 PDT Thiago Macieira wrote: > On Wednesday, 11 July 2018 07:44:46 PDT Oleg Yadrov wrote: > > qDebug() << a.absolutePath().startsWith(b.absolutePath()); > > > > qDebug() << a.absolutePath().startsWith(c.absolutePath()); > > Except that this has a bug

Re: [Interest] Detecting subdirectories in QDir

2018-07-11 Thread Oleg Yadrov
Ha. I hope I didn't screw up this time. #include #include #include // returns true if 'a' is a subdirectory of 'b' bool isSubdirectory(QDir a, QDir b) { while (!a.isRoot()) { if (a.absolutePath() == b.absolutePath()) return true; a.cdUp(); }

Re: [Interest] Detecting subdirectories in QDir

2018-07-11 Thread Thiago Macieira
On Wednesday, 11 July 2018 07:44:46 PDT Oleg Yadrov wrote: > qDebug() << a.absolutePath().startsWith(b.absolutePath()); > > qDebug() << a.absolutePath().startsWith(c.absolutePath()); Except that this has a bug (which we had in Qt too): these two directories are considered to be parent-ch

Re: [Interest] Detecting subdirectories in QDir

2018-07-11 Thread Oleg Yadrov
Hi there, You can compare their absolute paths. #include #include #include 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");

[Interest] Detecting subdirectories in QDir

2018-07-11 Thread Tom Isaacson via Interest
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@qt-project.org http://lists.qt-pro