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

Function NFD_OpenDialogMultipleN

extern/nfd/nfd_win.cpp:404–465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

402}
403
404nfdresult_t NFD_OpenDialogMultipleN(const nfdpathset_t** outPaths,
405 const nfdnfilteritem_t* filterList,
406 nfdfiltersize_t filterCount,
407 const nfdnchar_t* defaultPath) {
408 ::IFileOpenDialog* fileOpenDialog(nullptr);
409
410 // Create dialog
411 HRESULT result = ::CoCreateInstance(::CLSID_FileOpenDialog,
412 nullptr,
413 CLSCTX_ALL,
414 ::IID_IFileOpenDialog,
415 reinterpret_cast<void**>(&fileOpenDialog));
416
417 if (!SUCCEEDED(result)) {
418 NFDi_SetError("Could not create dialog.");
419 return NFD_ERROR;
420 }
421
422 // make sure we remember to free the dialog
423 Release_Guard<::IFileOpenDialog> fileOpenDialogGuard(fileOpenDialog);
424
425 // Build the filter list
426 if (!AddFiltersToDialog(fileOpenDialog, filterList, filterCount)) {
427 return NFD_ERROR;
428 }
429
430 // Set auto-completed default extension
431 if (!SetDefaultExtension(fileOpenDialog, filterList, filterCount)) {
432 return NFD_ERROR;
433 }
434
435 // Set the default path
436 if (!SetDefaultPath(fileOpenDialog, defaultPath)) {
437 return NFD_ERROR;
438 }
439
440 // Set a flag for multiple options and file system items only
441 if (!AddOptions(fileOpenDialog, ::FOS_FORCEFILESYSTEM | ::FOS_ALLOWMULTISELECT)) {
442 return NFD_ERROR;
443 }
444
445 // Show the dialog.
446 result = fileOpenDialog->Show(nullptr);
447 if (SUCCEEDED(result)) {
448 ::IShellItemArray* shellItems;
449 result = fileOpenDialog->GetResults(&shellItems);
450 if (!SUCCEEDED(result)) {
451 NFDi_SetError("Could not get shell items.");
452 return NFD_ERROR;
453 }
454
455 // save the path set to the output
456 *outPaths = static_cast<void*>(shellItems);
457
458 return NFD_OKAY;
459 } else if (result == HRESULT_FROM_WIN32(ERROR_CANCELLED)) {
460 return NFD_CANCEL;
461 } else {

Callers 2

NFD_OpenDialogMultipleU8Function · 0.70
OpenDialogMultipleFunction · 0.50

Calls 5

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

Tested by

no test coverage detected