| 55 | } |
| 56 | |
| 57 | std::optional<fs::path> GetLoadPath(const fs::path &initFName, const fs::path &initPath, const CStringW &FilterName, const CStringW &FilterExt) { |
| 58 | CStringW defaultExt = FilterExt; |
| 59 | int index = defaultExt.Find(L';'); |
| 60 | if (index != -1) |
| 61 | defaultExt.Truncate(index); |
| 62 | |
| 63 | CStringW filter = LoadDefaultFilter(FilterName, FilterExt); |
| 64 | CFileDialog FileDialog(TRUE, !defaultExt.IsEmpty() ? (LPCWSTR)defaultExt : nullptr, initFName.c_str(), OFN_HIDEREADONLY, filter); |
| 65 | if (!initPath.empty()) |
| 66 | FileDialog.m_pOFN->lpstrInitialDir = initPath.c_str(); |
| 67 | |
| 68 | if (FileDialog.DoModal() != IDOK) |
| 69 | return std::nullopt; |
| 70 | |
| 71 | return (LPCWSTR)FileDialog.GetPathName(); |
| 72 | } |
| 73 | |
| 74 | std::optional<fs::path> GetLoadPath(const fs::path &initFName, const fs::path &initPath, UINT nFilterID, const CStringW &FilterExt) { |
| 75 | return GetLoadPath(initFName, initPath, CStringW(MAKEINTRESOURCEW(nFilterID)), FilterExt); |
no test coverage detected