Ok, this doesn't look very "Qt-ish". How about:
if(!dir.isReadable()) return false;
QFileInfoList entries = dir.entryInfoList();
for(QList<QFileInfo>::iterator it = entries.begin(); it!=entries.end();++it){
if(finfo.fileName()=="." || finfo.fileName()=="..") continue;
if(finfo.isDir()){ copyDir(finfo.filePath()); continue; }
if(finfo.isSymLink()) { /* do something here */ continue; }
if(finfo.isFile() && file.isReadable()){
QFile file(finfo.
filePath());
file.copy(dirdest.absoluteFilePath(finfo.fileName()));
} else return false;
}
return true;
}
bool copyDir(const QString &src, const QString &dest){
QDir dir(src);
QDir dirdest(dest);
if(!dir.isReadable()) return false;
QFileInfoList entries = dir.entryInfoList();
for(QList<QFileInfo>::iterator it = entries.begin(); it!=entries.end();++it){
QFileInfo &finfo = *it;
if(finfo.fileName()=="." || finfo.fileName()=="..") continue;
if(finfo.isDir()){ copyDir(finfo.filePath()); continue; }
if(finfo.isSymLink()) { /* do something here */ continue; }
if(finfo.isFile() && file.isReadable()){
QFile file(finfo.filePath());
file.copy(dirdest.absoluteFilePath(finfo.fileName()));
} else return false;
}
return true;
}
To copy to clipboard, switch view to plain text mode
I didn't compile/test it, so it may not work, but shows the right direction.
Bookmarks