MCPcopy Create free account
hub / github.com/MultiMC/Launcher / doExport

Method doExport

launcher/ui/dialogs/ExportInstanceDialog.cpp:379–412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

377}
378
379bool ExportInstanceDialog::doExport()
380{
381 auto name = FS::RemoveInvalidFilenameChars(m_instance->name());
382
383 const QString output = QFileDialog::getSaveFileName(
384 this, tr("Export %1").arg(m_instance->name()),
385 FS::PathCombine(QDir::homePath(), name + ".zip"), "Zip (*.zip)", nullptr, QFileDialog::DontConfirmOverwrite);
386 if (output.isEmpty())
387 {
388 return false;
389 }
390 if (QFile::exists(output))
391 {
392 int ret =
393 QMessageBox::question(this, tr("Overwrite?"),
394 tr("This file already exists. Do you want to overwrite it?"),
395 QMessageBox::No, QMessageBox::Yes);
396 if (ret == QMessageBox::No)
397 {
398 return false;
399 }
400 }
401
402 SaveIcon(m_instance);
403
404 auto & blocked = proxyModel->blockedPaths();
405 using std::placeholders::_1;
406 if (!JlCompress::compressDir(output, m_instance->instanceRoot(), name, std::bind(&SeparatorPrefixTree<'/'>::covers, blocked, _1)))
407 {
408 QMessageBox::warning(this, tr("Error"), tr("Unable to export instance"));
409 return false;
410 }
411 return true;
412}
413
414void ExportInstanceDialog::done(int result)
415{

Callers

nothing calls this directly

Calls 6

PathCombineFunction · 0.85
SaveIconFunction · 0.85
isEmptyMethod · 0.80
instanceRootMethod · 0.80
nameMethod · 0.45

Tested by

no test coverage detected