bool FileManager::copyFolder(QString sourceFolder, QString destFolder){ QDir sourceDir(sourceFolder); if(!sourceDir.exists()) return false; QDir destDir(destFolder); if(!destDir.exists()) { destDir.mkdir(destFolder); } QStringList files = sourceDir.entryList(QDir::Files); for(int i = 0; i< files.count(); i++) { QString srcName = sourceFolder + "/" + files[i]; QString destName = destFolder + "/" + files[i]; QFile::copy(srcName, destName); } files.clear(); files = sourceDir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); for(int i = 0; i< files.count(); i++) { QString srcName = sourceFolder + "/" + files[i]; QString destName = destFolder + "/" + files[i]; copyFolder(srcName, destName); }}
void ThreadCopy::run(){ FileManager f; f.copyFolder("","");}
connect(&f,SIGNAL(copyDone()),SLOT(my_slot()));