]> git.sesse.net Git - casparcg/commitdiff
#283
authorHelge Norberg <helge.norberg@gmail.com>
Wed, 30 Jul 2014 12:24:56 +0000 (14:24 +0200)
committerHelge Norberg <helge.norberg@gmail.com>
Wed, 30 Jul 2014 12:24:56 +0000 (14:24 +0200)
Added support for using a different configuration file at startup than the default casparcg.config by simply adding the name of the file to use as the first command line argument to casparcg.exe.

shell/main.cpp

index f7cd96ca9df6c907191e3811196b08bffc59288f..c26d6b7bb68511010f7fbe53ee81d7c413da3ccb 100644 (file)
@@ -184,7 +184,7 @@ std::wstring make_upper_case(const std::wstring& str)
        return boost::to_upper_copy(str);\r
 }\r
 \r
-int main(int argc, wchar_t* argv[])\r
+int main(int argc, char* argv[])\r
 {      \r
        static_assert(sizeof(void*) == 4, "64-bit code generation is not supported.");\r
        \r
@@ -234,11 +234,17 @@ int main(int argc, wchar_t* argv[])
 \r
        bool restart = false;\r
        tbb::task_scheduler_init init;\r
+       std::wstring config_file_name(L"casparcg.config");\r
        \r
        try \r
        {\r
                // Configure environment properties from configuration.\r
-               caspar::env::configure(L"casparcg.config");\r
+               if (argc >= 2)\r
+               {\r
+                       config_file_name = caspar::widen(argv[1]);\r
+               }\r
+\r
+               caspar::env::configure(config_file_name);\r
                                \r
                caspar::log::set_log_level(caspar::env::properties().get(L"configuration.log-level", L"debug"));\r
 \r
@@ -260,7 +266,7 @@ int main(int argc, wchar_t* argv[])
                std::wstringstream str;\r
                boost::property_tree::xml_writer_settings<wchar_t> w(' ', 3);\r
                boost::property_tree::write_xml(str, caspar::env::properties(), w);\r
-               CASPAR_LOG(info) << L"casparcg.config:\n-----------------------------------------\n" << str.str().c_str() << L"-----------------------------------------";\r
+               CASPAR_LOG(info) << config_file_name << L":\n-----------------------------------------\n" << str.str().c_str() << L"-----------------------------------------";\r
                tbb::atomic<bool> wait_for_keypress;\r
                wait_for_keypress = false;\r
 \r
@@ -374,7 +380,7 @@ int main(int argc, wchar_t* argv[])
        catch(boost::property_tree::file_parser_error&)\r
        {\r
                CASPAR_LOG_CURRENT_EXCEPTION();\r
-               CASPAR_LOG(fatal) << L"Unhandled configuration error in main thread. Please check the configuration file (casparcg.config) for errors.";\r
+               CASPAR_LOG(fatal) << L"Unhandled configuration error in main thread. Please check the configuration file (" << config_file_name << L") for errors.";\r
                system("pause");        \r
        }\r
        catch(...)\r