Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy directory using Qt

Tags:

I want to copy a directory from one drive to another drive. My selected directory contains many sub directories and files.

How can I implement the same using Qt?

like image 885
Sijith Avatar asked Mar 29 '10 08:03

Sijith


1 Answers

void copyPath(QString src, QString dst) {     QDir dir(src);     if (! dir.exists())         return;      foreach (QString d, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {         QString dst_path = dst + QDir::separator() + d;         dir.mkpath(dst_path);         copyPath(src+ QDir::separator() + d, dst_path);     }      foreach (QString f, dir.entryList(QDir::Files)) {         QFile::copy(src + QDir::separator() + f, dst + QDir::separator() + f);     } } 
like image 80
petch Avatar answered Nov 06 '22 07:11

petch