| 397 | } |
| 398 | |
| 399 | bool ExportInstanceDialog::doExport() |
| 400 | { |
| 401 | auto name = FS::RemoveInvalidFilenameChars(m_instance->name()); |
| 402 | |
| 403 | const QString output = QFileDialog::getSaveFileName( |
| 404 | this, tr("Export %1").arg(m_instance->name()), |
| 405 | FS::PathCombine(QDir::homePath(), name + ".zip"), "Zip (*.zip)", nullptr, QFileDialog::DontConfirmOverwrite); |
| 406 | if (output.isEmpty()) |
| 407 | { |
| 408 | return false; |
| 409 | } |
| 410 | if (QFile::exists(output)) |
| 411 | { |
| 412 | int ret = |
| 413 | QMessageBox::question(this, tr("Overwrite?"), |
| 414 | tr("This file already exists. Do you want to overwrite it?"), |
| 415 | QMessageBox::No, QMessageBox::Yes); |
| 416 | if (ret == QMessageBox::No) |
| 417 | { |
| 418 | return false; |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | SaveIcon(m_instance); |
| 423 | |
| 424 | auto & blocked = proxyModel->blockedPaths(); |
| 425 | using std::placeholders::_1; |
| 426 | auto files = QFileInfoList(); |
| 427 | if (!MMCZip::collectFileListRecursively(m_instance->instanceRoot(), nullptr, &files, |
| 428 | std::bind(&SeparatorPrefixTree<'/'>::covers, blocked, _1))) { |
| 429 | QMessageBox::warning(this, tr("Error"), tr("Unable to export instance")); |
| 430 | return false; |
| 431 | } |
| 432 | if (!MMCZip::compressDirFiles(output, m_instance->instanceRoot(), files)) |
| 433 | { |
| 434 | QMessageBox::warning(this, tr("Error"), tr("Unable to export instance")); |
| 435 | return false; |
| 436 | } |
| 437 | return true; |
| 438 | } |
| 439 | |
| 440 | void ExportInstanceDialog::done(int result) |
| 441 | { |
nothing calls this directly
no test coverage detected