MCPcopy Create free account
hub / github.com/bazz1tv/snestracker / SetDefaultPath

Function SetDefaultPath

pc/ext/NativeFileDialog/nfd_win.cpp:350–382  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

348
349
350static nfdresult_t SetDefaultPath( IFileDialog *dialog, const char *defaultPath )
351{
352 if ( !defaultPath || strlen(defaultPath) == 0 )
353 return NFD_OKAY;
354
355 wchar_t *defaultPathW = {0};
356 CopyNFDCharToWChar( defaultPath, &defaultPathW );
357
358 IShellItem *folder;
359 HRESULT result = SHCreateItemFromParsingName( defaultPathW, NULL, IID_PPV_ARGS(&folder) );
360
361 // Valid non results.
362 if ( result == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) || result == HRESULT_FROM_WIN32(ERROR_INVALID_DRIVE) )
363 {
364 NFDi_Free( defaultPathW );
365 return NFD_OKAY;
366 }
367
368 if ( !SUCCEEDED(result) )
369 {
370 NFDi_SetError("Error creating ShellItem");
371 NFDi_Free( defaultPathW );
372 return NFD_ERROR;
373 }
374
375 // Could also call SetDefaultFolder(), but this guarantees defaultPath -- more consistency across API.
376 dialog->SetFolder( folder );
377
378 NFDi_Free( defaultPathW );
379 folder->Release();
380
381 return NFD_OKAY;
382}
383
384/* public */
385

Callers 4

NFD_OpenDialogFunction · 0.70
NFD_OpenDialogMultipleFunction · 0.70
NFD_SaveDialogFunction · 0.70
NFD_PickFolderFunction · 0.70

Calls 3

CopyNFDCharToWCharFunction · 0.85
NFDi_FreeFunction · 0.70
NFDi_SetErrorFunction · 0.70

Tested by

no test coverage detected