MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / NFD_SaveDialogN

Function NFD_SaveDialogN

extern/nfd/nfd_win.cpp:467–542  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

465}
466
467nfdresult_t NFD_SaveDialogN(nfdnchar_t** outPath,
468 const nfdnfilteritem_t* filterList,
469 nfdfiltersize_t filterCount,
470 const nfdnchar_t* defaultPath,
471 const nfdnchar_t* defaultName) {
472 ::IFileSaveDialog* fileSaveDialog;
473
474 // Create dialog
475 HRESULT result = ::CoCreateInstance(::CLSID_FileSaveDialog,
476 nullptr,
477 CLSCTX_ALL,
478 ::IID_IFileSaveDialog,
479 reinterpret_cast<void**>(&fileSaveDialog));
480
481 if (!SUCCEEDED(result)) {
482 NFDi_SetError("Could not create dialog.");
483 return NFD_ERROR;
484 }
485
486 // make sure we remember to free the dialog
487 Release_Guard<::IFileSaveDialog> fileSaveDialogGuard(fileSaveDialog);
488
489 // Build the filter list
490 if (!AddFiltersToDialog(fileSaveDialog, filterList, filterCount)) {
491 return NFD_ERROR;
492 }
493
494 // Set default extension
495 if (!SetDefaultExtension(fileSaveDialog, filterList, filterCount)) {
496 return NFD_ERROR;
497 }
498
499 // Set the default path
500 if (!SetDefaultPath(fileSaveDialog, defaultPath)) {
501 return NFD_ERROR;
502 }
503
504 // Set the default name
505 if (!SetDefaultName(fileSaveDialog, defaultName)) {
506 return NFD_ERROR;
507 }
508
509 // Only show file system items
510 if (!AddOptions(fileSaveDialog, ::FOS_FORCEFILESYSTEM)) {
511 return NFD_ERROR;
512 }
513
514 // Show the dialog.
515 result = fileSaveDialog->Show(nullptr);
516 if (SUCCEEDED(result)) {
517 // Get the file name
518 ::IShellItem* psiResult;
519 result = fileSaveDialog->GetResult(&psiResult);
520 if (!SUCCEEDED(result)) {
521 NFDi_SetError("Could not get shell item from dialog.");
522 return NFD_ERROR;
523 }
524 Release_Guard<::IShellItem> psiResultGuard(psiResult);

Callers 2

NFD_SaveDialogU8Function · 0.70
SaveDialogFunction · 0.50

Calls 6

SetDefaultExtensionFunction · 0.85
AddOptionsFunction · 0.85
NFDi_SetErrorFunction · 0.70
AddFiltersToDialogFunction · 0.70
SetDefaultPathFunction · 0.70
SetDefaultNameFunction · 0.70

Tested by

no test coverage detected