From 6829a1c1b3c577cdd6bc6d206dd52608b0a976ab Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 17 Oct 2018 20:18:27 +0100 Subject: Revert overwrite changes; remove our replacement of file extension (#1383). --- src/wx/config_dialog.cc | 96 ++++++++++++++++++++------------------------ src/wx/full_config_dialog.cc | 5 +-- src/wx/wx_util.cc | 11 ----- src/wx/wx_util.h | 1 - 4 files changed, 44 insertions(+), 69 deletions(-) diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index e55de008f..34bdee8b3 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -526,17 +526,15 @@ CertificateChainEditor::export_certificate () } if (d->ShowModal () == wxID_OK) { - optional path = path_from_file_dialog (d, "pem"); - if (path) { - FILE* f = fopen_boost (*path, "w"); - if (!f) { - throw OpenFileError (*path, errno, false); - } - - string const s = j->certificate (true); - fwrite (s.c_str(), 1, s.length(), f); - fclose (f); + boost::filesystem::path path (wx_to_std(d->GetPath())); + FILE* f = fopen_boost (path, "w"); + if (!f) { + throw OpenFileError (path, errno, false); } + + string const s = j->certificate (true); + fwrite (s.c_str(), 1, s.length(), f); + fclose (f); } d->Destroy (); } @@ -701,17 +699,15 @@ CertificateChainEditor::export_private_key () ); if (d->ShowModal () == wxID_OK) { - optional path = path_from_file_dialog (d, "pem"); - if (path) { - FILE* f = fopen_boost (*path, "w"); - if (!f) { - throw OpenFileError (*path, errno, false); - } - - string const s = _get()->key().get (); - fwrite (s.c_str(), 1, s.length(), f); - fclose (f); + boost::filesystem::path path (wx_to_std(d->GetPath())); + FILE* f = fopen_boost (path, "w"); + if (!f) { + throw OpenFileError (path, errno, false); } + + string const s = _get()->key().get (); + fwrite (s.c_str(), 1, s.length(), f); + fclose (f); } d->Destroy (); } @@ -799,20 +795,18 @@ KeysPage::export_decryption_chain_and_key () ); if (d->ShowModal () == wxID_OK) { - optional path = path_from_file_dialog (d, "dom"); - if (path) { - FILE* f = fopen_boost (*path, "w"); - if (!f) { - throw OpenFileError (wx_to_std (d->GetPath ()), errno, false); - } - - string const chain = Config::instance()->decryption_chain()->chain(); - fwrite (chain.c_str(), 1, chain.length(), f); - optional const key = Config::instance()->decryption_chain()->key(); - DCPOMATIC_ASSERT (key); - fwrite (key->c_str(), 1, key->length(), f); - fclose (f); + boost::filesystem::path path (wx_to_std(d->GetPath())); + FILE* f = fopen_boost (path, "w"); + if (!f) { + throw OpenFileError (path, errno, false); } + + string const chain = Config::instance()->decryption_chain()->chain(); + fwrite (chain.c_str(), 1, chain.length(), f); + optional const key = Config::instance()->decryption_chain()->key(); + DCPOMATIC_ASSERT (key); + fwrite (key->c_str(), 1, key->length(), f); + fclose (f); } d->Destroy (); @@ -879,17 +873,15 @@ KeysPage::export_decryption_chain () ); if (d->ShowModal () == wxID_OK) { - optional path = path_from_file_dialog (d, "pem"); - if (path) { - FILE* f = fopen_boost (*path, "w"); - if (!f) { - throw OpenFileError (*path, errno, false); - } - - string const s = Config::instance()->decryption_chain()->chain(); - fwrite (s.c_str(), 1, s.length(), f); - fclose (f); + boost::filesystem::path path (wx_to_std(d->GetPath())); + FILE* f = fopen_boost (path, "w"); + if (!f) { + throw OpenFileError (path, errno, false); } + + string const s = Config::instance()->decryption_chain()->chain(); + fwrite (s.c_str(), 1, s.length(), f); + fclose (f); } d->Destroy (); } @@ -903,17 +895,15 @@ KeysPage::export_decryption_certificate () ); if (d->ShowModal () == wxID_OK) { - optional path = path_from_file_dialog (d, "pem"); - if (path) { - FILE* f = fopen_boost (*path, "w"); - if (!f) { - throw OpenFileError (*path, errno, false); - } - - string const s = Config::instance()->decryption_chain()->leaf().certificate (true); - fwrite (s.c_str(), 1, s.length(), f); - fclose (f); + boost::filesystem::path path (wx_to_std(d->GetPath())); + FILE* f = fopen_boost (path, "w"); + if (!f) { + throw OpenFileError (path, errno, false); } + + string const s = Config::instance()->decryption_chain()->leaf().certificate (true); + fwrite (s.c_str(), 1, s.length(), f); + fclose (f); } d->Destroy (); diff --git a/src/wx/full_config_dialog.cc b/src/wx/full_config_dialog.cc index 974635a8b..96a4c86e9 100644 --- a/src/wx/full_config_dialog.cc +++ b/src/wx/full_config_dialog.cc @@ -196,10 +196,7 @@ private: ); if (d->ShowModal () == wxID_OK) { - optional path = path_from_file_dialog (d, "xml"); - if (path) { - boost::filesystem::copy_file (Config::instance()->cinemas_file(), *path); - } + boost::filesystem::copy_file (Config::instance()->cinemas_file(), wx_to_std(d->GetPath())); } d->Destroy (); } diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index db6340031..0b1c68319 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -463,17 +463,6 @@ maybe_show_splash () return splash; } -optional -path_from_file_dialog (wxFileDialog* dialog, string 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(); - } - return p; -} - double calculate_mark_interval (double mark_interval) { diff --git a/src/wx/wx_util.h b/src/wx/wx_util.h index ee06c3807..0438fcee2 100644 --- a/src/wx/wx_util.h +++ b/src/wx/wx_util.h @@ -86,7 +86,6 @@ extern std::string string_client_data (wxClientData* o); extern wxString time_to_timecode (DCPTime t, double fps); extern void setup_audio_channels_choice (wxChoice* choice, int minimum); extern wxSplashScreen* maybe_show_splash (); -extern boost::optional path_from_file_dialog (wxFileDialog* dialog, std::string extension); extern double calculate_mark_interval (double start); extern void checked_set (FilePickerCtrl* widget, boost::filesystem::path value); -- cgit v1.2.3