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

Function SetDefaultPath

extern/nfd/nfd_win.cpp:234–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232}
233
234nfdresult_t SetDefaultPath(IFileDialog* dialog, const nfdnchar_t* defaultPath) {
235 if (!defaultPath || !*defaultPath) return NFD_OKAY;
236
237 IShellItem* folder;
238 HRESULT result = SHCreateItemFromParsingName(defaultPath, nullptr, IID_PPV_ARGS(&folder));
239
240 // Valid non results.
241 if (result == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) ||
242 result == HRESULT_FROM_WIN32(ERROR_INVALID_DRIVE)) {
243 return NFD_OKAY;
244 }
245
246 if (!SUCCEEDED(result)) {
247 NFDi_SetError("Failed to create ShellItem for setting the default path.");
248 return NFD_ERROR;
249 }
250
251 Release_Guard<IShellItem> folderGuard(folder);
252
253 // SetDefaultFolder() might use another recently used folder if available, so the user doesn't
254 // need to keep navigating back to the default folder (recommended by Windows). change to
255 // SetFolder() if you always want to use the default folder
256 if (!SUCCEEDED(dialog->SetFolder(folder))) {
257 NFDi_SetError("Failed to set default path.");
258 return NFD_ERROR;
259 }
260
261 return NFD_OKAY;
262}
263
264nfdresult_t SetDefaultName(IFileDialog* dialog, const nfdnchar_t* defaultName) {
265 if (!defaultName || !*defaultName) return NFD_OKAY;

Callers 4

NFD_OpenDialogNFunction · 0.70
NFD_OpenDialogMultipleNFunction · 0.70
NFD_SaveDialogNFunction · 0.70
NFD_PickFolderNFunction · 0.70

Calls 1

NFDi_SetErrorFunction · 0.70

Tested by

no test coverage detected