diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-10-17 19:23:18 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-10-17 19:23:18 +0100 |
| commit | ce9bb37168f52a8d1348e1334fc15d5778fffa75 (patch) | |
| tree | e77c65084e72290f77d5346e4020d3357403c018 /src/wx/wx_util.cc | |
| parent | 4eaecb1841d3a80a4f06613ad4c0bd44d89285a9 (diff) | |
Prevent un-prompted overwrite of files when exporting things from config (#1383).
Diffstat (limited to 'src/wx/wx_util.cc')
| -rw-r--r-- | src/wx/wx_util.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index c9185ec97..db6340031 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -463,10 +463,15 @@ maybe_show_splash () return splash; } -boost::filesystem::path +optional<boost::filesystem::path> path_from_file_dialog (wxFileDialog* dialog, string extension) { - return boost::filesystem::path(wx_to_std(dialog->GetPath())).replace_extension(extension); + boost::filesystem::path p(wx_to_std(dialog->GetPath())); + p.replace_extension(extension); + if (boost::filesystem::is_regular_file(p) && !confirm_dialog(dialog, wxString::Format(_("A file named %s already exists. Do you want to replace it?"), std_to_wx(p.filename().string())))) { + return optional<boost::filesystem::path>(); + } + return p; } double |
