The problem is that as I wrote in the comment, you are constructing the file info with the full path as opposed to relative path as you wish to have.
You could work this issue around by:
#include
#include #include #include #include int main(){ QDir targetDir1("/home/brett/sweetback"); targetDir1.mkdir("sweetassurfwear"); QDir targetDir("/usr/local"); targetDir.setFilter(QDir::NoDotAndDotDot| QDir::Dirs | QDir::Files); QDirIterator it(targetDir, QDirIterator::Subdirectories); while (it.hasNext()) { it.next(); QFileInfo Info = it.fileInfo(); QString testName = Info.fileName(); QString testPath = Info.absoluteFilePath().mid(it.path().size()); qDebug() << "TEST:" << testPath; if(Info.isDir()) { // QString cpd = "/home/brett/sweetback/sweetassurfwear/"; // targetDir.mkdir(cpd+testName); QString dirname = Info.filePath(); } } return 0;}TEMPLATE = appTARGET = mainQT = coreSOURCES += main.cppqmake && make && ./mainNote that, you do not really need to build a file info based on the path since the diriterator can return that directly.
Disclaimer: this is just a workaround to get going. There must be a nicer solution.
View the original article here
ليست هناك تعليقات:
إرسال تعليق