QAbstractButton *noToAllButton = msgBox.addButton(QMessageBox::NoToAll);
QAbstractButton *abortButton = msgBox.addButton(tr("Abort"), QMessageBox::DestructiveRole);
QAbstractButton *askButton = 0;
+ QAbstractButton *skipDirButton = 0;
if (dirOverDir) {
msgBox.setText(tr("Directory %1 already exists. Overwrite the files inside?")
.arg(FileOperator::shortenPath(fileName)));
askButton = msgBox.addButton(tr("Ask"), QMessageBox::AcceptRole);
+ skipDirButton = msgBox.addButton(tr("Skip"), QMessageBox::NoRole);
} else {
msgBox.setText(tr("File %1 already exists. Overwrite?").arg(FileOperator::shortenPath(fileName)));
}
manipulator->setResponse(KEEP, true);
} else if (msgBox.clickedButton() == askButton) {
manipulator->setResponse(NONE, true);
+ } else if (msgBox.clickedButton() == skipDirButton) {
+ manipulator->setResponse(SKIP_DIR);
}
}
if (abort) return;
- if (response == FileOperator::KEEP) {
- updateProgress(fileSizeMap[path]);
- removeExcludeFiles.insert(path);
- return;
- }
-
if (file.isDir()) {
+ // save the overwrite response, because the response variable will get ovewritten in remove(...)
FileOperator::Response overwriteResponse = response;
if (newFile.exists() && !newFile.isDir()) {
+ // overwriting a file, so check for KEEP and handle it
+ if (response == FileOperator::KEEP) {
+ updateProgress(fileSizeMap[path]);
+ removeExcludeFiles.insert(path);
+ return;
+ }
+
+ // if it should not be kept, remove it and return on failure
if(!remove(newPath)) {
updateProgress(fileSizeMap[path]);
return;
}
+ // create new info since we deleted the file - is it needed?
newFile = QFileInfo(newPath);
+ } else {
+ // overwriting a directory - response KEEP means to keep the files inside,
+ // SKIP_DIR means to skip the dir completely
+ if (response == FileOperator::SKIP_DIR) {
+ updateProgress(fileSizeMap[path]);
+ removeExcludeFiles.insert(path);
+ return;
+ }
}
if (!newFile.exists()) {
tr("Error creating directory %1."), newPath)
}
+ // we've done the job with the dir, so update progress and recurse into the dir
updateProgress(1);
+ // change the dest for the recursion
QDir destBackup = dest;
dest = newPath;
+ // and set overwriteAll to the response we got a while ago
+ // because it applies to the files inside the dir
FileOperator::Response tmpResp = overwriteAll;
overwriteAll = overwriteResponse;
dest = destBackup;
} else {
+ if (response == FileOperator::KEEP) {
+ updateProgress(fileSizeMap[path]);
+ removeExcludeFiles.insert(path);
+ return;
+ }
+
SPECIAL_COPY_ERROR_PROMPT(engine.isSequential(), tr("Cannot copy sequential file %1."), path)
if (newFile.exists() && newFile.isDir()) {
QString path = files[i].absoluteFilePath();
QFSFileEngine engine(path);
QString newPath = dest.absolutePath() + "/" + files[i].fileName();
+ QFileInfo newFile(newPath);
updateFile(path);
- OVERWRITE_PROMPT(files[i], QFileInfo(newPath))
+ OVERWRITE_PROMPT(files[i], newFile)
- if (response == FileOperator::KEEP) {
- if (abort) break;
- updateProgress(1);
- continue;
+ if (files[i].isDir() && newFile.exists() && newFile.isDir()) {
+ if (response == FileOperator::SKIP_DIR) {
+ if (abort) break;
+ updateProgress(1);
+ removeExcludeFiles.insert(path);
+ continue;
+ }
+ } else {
+ if (response == FileOperator::KEEP) {
+ if (abort) break;
+ updateProgress(1);
+ removeExcludeFiles.insert(path);
+ continue;
+ }
}
while (!abort && !engine.rename(newPath)) {
overwriteAll = tmpResp;
- ERROR_PROMPT(!engine.rmdir(path, false), tr("Error deleting directory %1."), path)
+ remove(files[i]);
break;
// source and target are nonmatching types(file and dir)