From 4f19455332f1f4cc4c313338b7fb0b6fc508d5b4 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 17 Feb 2016 10:11:24 +0000 Subject: [PATCH 1/1] Allow multiple configuration files in DCP-o-matic's directory. --- src/lib/config.cc | 16 ++++++++-------- src/lib/config.h | 4 ++-- src/tools/dcpomatic.cc | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/lib/config.cc b/src/lib/config.cc index 81acd9f62..d157207d0 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -139,7 +139,7 @@ Config::create_certificate_chain () void Config::read () { - if (!have_existing ()) { + if (!have_existing ("config.xml")) { /* Make a new set of signing certificates and key */ _signer_chain = create_certificate_chain (); /* And similar for decryption of KDMs */ @@ -149,7 +149,7 @@ Config::read () } cxml::Document f ("Config"); - f.read_file (file ()); + f.read_file (path ("config.xml")); optional c; optional version = f.optional_number_child ("Version"); @@ -298,7 +298,7 @@ Config::read () /** @return Filename to write configuration to */ boost::filesystem::path -Config::file (bool create_directories) +Config::path (string file, bool create_directories) { boost::filesystem::path p; #ifdef DCPOMATIC_OSX @@ -315,7 +315,7 @@ Config::file (bool create_directories) if (create_directories) { boost::filesystem::create_directories (p, ec); } - p /= "config.xml"; + p /= file; return p; } @@ -433,11 +433,11 @@ Config::write () const } try { - doc.write_to_file_formatted (file().string ()); + doc.write_to_file_formatted (path("config.xml").string ()); } catch (xmlpp::exception& e) { string s = e.what (); trim (s); - throw FileError (s, file ()); + throw FileError (s, path("config.xml")); } } @@ -507,7 +507,7 @@ Config::add_to_history (boost::filesystem::path p) } bool -Config::have_existing () +Config::have_existing (string file) { - return boost::filesystem::exists (file (false)); + return boost::filesystem::exists (path (file, false)); } diff --git a/src/lib/config.h b/src/lib/config.h index 049b3663c..806853083 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -458,11 +458,11 @@ public: static Config* instance (); static void drop (); static void restore_defaults (); - static bool have_existing (); + static bool have_existing (std::string); private: Config (); - static boost::filesystem::path file (bool create_directories = true); + static boost::filesystem::path path (std::string file, bool create_directories = true); void read (); void set_defaults (); void set_kdm_email_to_default (); diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index b853851d7..1a8532134 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -935,7 +935,7 @@ private: wxSplashScreen* splash = 0; try { - if (!Config::have_existing ()) { + if (!Config::have_existing ("config.xml")) { wxBitmap bitmap; boost::filesystem::path p = shared_path () / "splash.png"; if (bitmap.LoadFile (std_to_wx (p.string ()), wxBITMAP_TYPE_PNG)) { -- 2.30.2