Virtual ISO: Fix Windows file dialog failing with a folder loaded

This commit is contained in:
RichardG867
2022-07-09 16:31:21 -03:00
parent bcd12099c7
commit af7230496b
2 changed files with 6 additions and 4 deletions

View File

@@ -174,7 +174,8 @@ file_dlg_w(HWND hwnd, WCHAR *f, WCHAR *fn, WCHAR *title, int save)
* not use the contents of szFile to initialize itself.
*/
memset(ofn.lpstrFile, 0x00, 512 * sizeof(WCHAR));
memcpy(ofn.lpstrFile, fn, (wcslen(fn) << 1) + 2);
if (fn)
memcpy(ofn.lpstrFile, fn, (wcslen(fn) << 1) + 2);
ofn.nMaxFile = sizeof_w(wopenfilestring);
ofn.lpstrFilter = f;
ofn.nFilterIndex = 1;
@@ -214,11 +215,12 @@ file_dlg(HWND hwnd, WCHAR *f, char *fn, char *title, int save)
{
WCHAR ufn[512], title_buf[512];
mbstoc16s(ufn, fn, strlen(fn) + 1);
if (fn)
mbstoc16s(ufn, fn, strlen(fn) + 1);
if (title)
mbstoc16s(title_buf, title, sizeof title_buf);
return(file_dlg_w(hwnd, f, ufn, title ? title_buf : NULL, save));
return(file_dlg_w(hwnd, f, fn ? ufn : NULL, title ? title_buf : NULL, save));
}

View File

@@ -670,7 +670,7 @@ media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
break;
case IDM_CDROM_IMAGE:
if (!file_dlg_st(hwnd, IDS_2140, cdrom[id].image_path, NULL, 0)) {
if (!file_dlg_st(hwnd, IDS_2140, cdrom[id].is_dir ? NULL : cdrom[id].image_path, NULL, 0)) {
cdrom_mount(id, openfilestring);
}
break;