Allow multiple configuration files in DCP-o-matic's directory.
authorCarl Hetherington <cth@carlh.net>
Wed, 17 Feb 2016 10:11:24 +0000 (10:11 +0000)
committerCarl Hetherington <cth@carlh.net>
Wed, 17 Feb 2016 10:11:24 +0000 (10:11 +0000)
src/lib/config.cc
src/lib/config.h
src/tools/dcpomatic.cc

index 81acd9f624389c02f2be9370ef9d53d25eb70085..d157207d05e8c41b92239ee6736e80cadc1cc197 100644 (file)
@@ -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<string> c;
 
        optional<int> version = f.optional_number_child<int> ("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));
 }
index 049b3663c70b416f1144cc786301cceba0638bd5..806853083e7e47b6d90752b5b8bdbbebd5dd4e71 100644 (file)
@@ -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 ();
index b853851d7c7328572d472fd707f6114a4b5cef03..1a85321340314fec10ee39263f9c8350d4588f99 100644 (file)
@@ -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)) {