bool CFileBrowser::copyFilesToDevice(CLink * d,
                                    const QStringList & filenames,
                                    const QString & targetDir){
    int i;
    for(i=0; i < filenames.size(); i++){
        QString filename(filenames.at(i));
        if( copyFileToDevice(d, filename, targetDir) == false ){
            return false;
        }

    }
    return true;
}
bool CFileBrowser::copyDirToDevice(CLink * d, QString srcDir, QString targetDir){
    QDir dir(srcDir);
    CNotify notify;
    QStringList files;
    bool ret;
    int i;
    files = dir.entryList(QDir::Files);
    for(i=0; i < files.size(); i++){
        ret = copyFileToDevice(d,
                             dir.path() + "/" + files.at(i),
                             targetDir
                             );
        if( ret < 0 ){
            return false;
        }
        notify.updateStatus("Copied " + files.at(i));
    }
    return true;
}
Exemplo n.º 3
0
bool QtCesterConnection::copyDirectoryToDevice(const QString &localSource, const QString &deviceDest, bool recursive)
{
    QTcpSocket* socket = NULL;
    QFileInfo info(localSource);
    if (!info.exists() || !info.isDir()) {
        END_ERROR(socket, "Input directory invalid");
    }

    createDirectory(deviceDest, true);
    QDir dir(localSource);
    QFileInfoList list = dir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
    foreach(QFileInfo item, list) {
        QString targetName = deviceDest + QLatin1String("\\") + item.fileName();
        if (item.isDir()) {
            if (recursive) {
                if (!copyDirectoryToDevice(item.absoluteFilePath() , targetName, recursive))
                    return false;
            }
        } else {
            if (!copyFileToDevice(item.absoluteFilePath(), targetName))
                return false;
        }
    }