| 34 | } |
| 35 | |
| 36 | std::optional<fs::path> GetSavePath(const fs::path &initFName, const fs::path &initPath, const CStringW &FilterName, const CStringW &FilterExt) { |
| 37 | CStringW defaultExt = FilterExt; |
| 38 | int index = defaultExt.Find(L';'); |
| 39 | if (index != -1) |
| 40 | defaultExt.Truncate(index); |
| 41 | |
| 42 | CStringW filter = LoadDefaultFilter(FilterName, FilterExt); |
| 43 | CFileDialog FileDialog(FALSE, !defaultExt.IsEmpty() ? (LPCWSTR)defaultExt : nullptr, initFName.c_str(), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, filter); |
| 44 | if (!initPath.empty()) |
| 45 | FileDialog.m_pOFN->lpstrInitialDir = initPath.c_str(); |
| 46 | |
| 47 | if (FileDialog.DoModal() != IDOK) |
| 48 | return std::nullopt; |
| 49 | |
| 50 | return (LPCWSTR)FileDialog.GetPathName(); |
| 51 | } |
| 52 | |
| 53 | std::optional<fs::path> GetSavePath(const fs::path &initFName, const fs::path &initPath, UINT nFilterID, const CStringW &FilterExt) { |
| 54 | return GetSavePath(initFName, initPath, CStringW(MAKEINTRESOURCEW(nFilterID)), FilterExt); |
no test coverage detected