Changeset 100093 in vbox
- Timestamp:
- Jun 7, 2023 12:25:18 PM (18 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/medium/viso
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.cpp
r100081 r100093 31 31 #include <QPushButton> 32 32 #include <QStyle> 33 #include <QTextStream> 33 34 34 35 /* GUI includes: */ … … 527 528 528 529 /* static */ 529 int UIVisoCreatorWidget::visoWriteQuotedString(PRTSTREAM pStrmDst, const char *pszPrefix,530 QString const &rStr, const char *pszPostFix)531 {532 QByteArray const utf8Array = rStr.toUtf8();533 const char *apszArgv[2] = { utf8Array.constData(), NULL };534 char *pszQuoted;535 int vrc = RTGetOptArgvToString(&pszQuoted, apszArgv, RTGETOPTARGV_CNV_QUOTE_BOURNE_SH);536 if (RT_SUCCESS(vrc))537 {538 if (pszPrefix)539 vrc = RTStrmPutStr(pStrmDst, pszPrefix);540 if (RT_SUCCESS(vrc))541 {542 vrc = RTStrmPutStr(pStrmDst, pszQuoted);543 if (pszPostFix && RT_SUCCESS(vrc))544 vrc = RTStrmPutStr(pStrmDst, pszPostFix);545 }546 RTStrFree(pszQuoted);547 }548 return vrc;549 }550 551 /* static */552 530 QUuid UIVisoCreatorWidget::createViso(UIActionPool *pActionPool, QWidget *pParent, 553 531 const QString &strDefaultFolder /* = QString() */, … … 564 542 if (pVisoCreator->exec(false /* not application modal */)) 565 543 { 566 QStringList files= pVisoCreator->entryList();544 QStringList VisoEntryList = pVisoCreator->entryList(); 567 545 QString strVisoName = pVisoCreator->visoName(); 568 546 if (strVisoName.isEmpty()) 569 547 strVisoName = strMachineName; 570 548 571 if ( files.empty() || files[0].isEmpty())549 if (VisoEntryList.empty() || VisoEntryList[0].isEmpty()) 572 550 { 573 551 delete pVisoCreator; … … 577 555 gEDataManager->setVISOCreatorRecentFolder(pVisoCreator->currentPath()); 578 556 579 /* Produce the VISO. */580 char szVisoPath[RTPATH_MAX];581 QString strFileName = QString("%1%2").arg(strVisoName).arg(".viso");582 583 557 QString strVisoSaveFolder(strDefaultFolder); 584 558 if (strVisoSaveFolder.isEmpty()) 585 559 strVisoSaveFolder = uiCommon().defaultFolderPathForType(UIMediumDeviceType_DVD); 586 560 587 int vrc = RTPathJoin(szVisoPath, sizeof(szVisoPath), strVisoSaveFolder.toUtf8().constData(), strFileName.toUtf8().constData()); 588 if (RT_SUCCESS(vrc)) 561 if (QDir(strVisoSaveFolder).exists()) 589 562 { 590 PRTSTREAM pStrmViso; 591 vrc = RTStrmOpen(szVisoPath, "w", &pStrmViso); 592 if (RT_SUCCESS(vrc)) 563 QString strFileName = QString("%1/%2%3").arg(strVisoSaveFolder).arg(strVisoName).arg(".viso"); 564 565 QFile file(strFileName); 566 if (file.open(QFile::WriteOnly | QFile::Truncate)) 593 567 { 594 RTUUID Uuid; 595 vrc = RTUuidCreate(&Uuid); 596 if (RT_SUCCESS(vrc)) 597 { 598 RTStrmPrintf(pStrmViso, "--iprt-iso-maker-file-marker-bourne-sh %RTuuid\n", &Uuid); 599 vrc = UIVisoCreatorWidget::visoWriteQuotedString(pStrmViso, "--volume-id=", strVisoName, "\n"); 600 601 for (int iFile = 0; iFile < files.size() && RT_SUCCESS(vrc); iFile++) 602 vrc = UIVisoCreatorWidget::visoWriteQuotedString(pStrmViso, NULL, files[iFile], "\n"); 603 604 /* Append custom options if any to the file: */ 605 const QStringList &customOptions = pVisoCreator->customOptions(); 606 foreach (QString strLine, customOptions) 607 RTStrmPrintf(pStrmViso, "%s\n", strLine.toUtf8().constData()); 608 609 RTStrmFlush(pStrmViso); 610 if (RT_SUCCESS(vrc)) 611 vrc = RTStrmError(pStrmViso); 612 } 613 614 RTStrmClose(pStrmViso); 568 QTextStream stream(&file); 569 stream << QString("%1 %2").arg("--iprt-iso-maker-file-marker-bourne-sh").arg(QUuid::createUuid().toString()); 570 stream << "\n"; 571 stream << VisoEntryList.join("\n"); 572 stream << pVisoCreator->customOptions().join("\n"); 573 file.close(); 615 574 } 616 575 } 617 618 /* Done. */ 619 if (RT_SUCCESS(vrc)) 620 { 621 delete pVisoCreator; 622 return uiCommon().openMedium(UIMediumDeviceType_DVD, QString(szVisoPath), pParent); 623 } 624 /** @todo error message. */ 625 else 626 { 627 delete pVisoCreator; 628 return QUuid(); 629 } 630 } 576 } // if (pVisoCreator->exec(false /* not application modal */)) 631 577 delete pVisoCreator; 632 578 return QUuid(); -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.h
r100071 r100093 93 93 QIToolBar *toolbar() const { return m_pToolBar; } 94 94 #endif 95 96 /**97 * Helper for createVisoMediumWithVisoCreator.98 * @returns IPRT status code.99 * @param pStrmDst Where to write the quoted string.100 * @param pszPrefix Stuff to put in front of it.101 * @param rStr The string to quote and write out.102 * @param pszPrefix Stuff to put after it.103 */104 static int visoWriteQuotedString(PRTSTREAM pStrmDst, const char *pszPrefix,105 QString const &rStr, const char *pszPostFix);106 95 107 96 protected:
Note:
See TracChangeset
for help on using the changeset viewer.