]> git.sesse.net Git - casparcg/blobdiff - common/env.cpp
2.0.2: Fixed problem with comments in xml configuration. Added automatic whitespace...
[casparcg] / common / env.cpp
index 571797609f2c99b58455e93832a672e5c04f0cd3..a47ae22fe0eaf04a995f677b0eff8a8228a70f8c 100644 (file)
@@ -32,6 +32,7 @@
 #include <boost/thread/once.hpp>\r
 \r
 #include <functional>\r
+#include <iostream>\r
 \r
 namespace caspar { namespace env {\r
 \r
@@ -40,7 +41,6 @@ using namespace boost::filesystem2;
 std::wstring media;\r
 std::wstring log;\r
 std::wstring ftemplate;\r
-std::wstring ftemplate_host;\r
 std::wstring data;\r
 boost::property_tree::ptree pt;\r
 \r
@@ -52,18 +52,23 @@ void check_is_configured()
 \r
 void configure(const std::string& filename)\r
 {\r
-       std::string initialPath = boost::filesystem::initial_path().file_string();\r
+       try\r
+       {\r
+               std::string initialPath = boost::filesystem::initial_path().file_string();\r
        \r
-       boost::property_tree::read_xml(initialPath + "\\" + filename, pt);\r
-\r
-       auto paths = pt.get_child("configuration.paths");\r
-       media = widen(paths.get("media-path", initialPath + "\\media\\"));\r
-       log = widen(paths.get("log-path", initialPath + "\\log\\"));\r
-       ftemplate = complete(wpath(widen(paths.get("template-path", initialPath + "\\template\\")))).string();\r
-\r
-       ftemplate_host = widen(paths.get("template-host", "cg.fth"));\r
-\r
-       data = widen(paths.get("data-path", initialPath + "\\data\\"));\r
+               boost::property_tree::read_xml(initialPath + "\\" + filename, pt, boost::property_tree::xml_parser::trim_whitespace | boost::property_tree::xml_parser::no_comments);\r
+\r
+               auto paths = pt.get_child("configuration.paths");\r
+               media = widen(paths.get("media-path", initialPath + "\\media\\"));\r
+               log = widen(paths.get("log-path", initialPath + "\\log\\"));\r
+               ftemplate = complete(wpath(widen(paths.get("template-path", initialPath + "\\template\\")))).string();          \r
+               data = widen(paths.get("data-path", initialPath + "\\data\\"));\r
+       }\r
+       catch(...)\r
+       {\r
+               std::wcout << L" ### Invalid configuration file. ###";\r
+               throw;\r
+       }\r
 }\r
        \r
 const std::wstring& media_folder()\r
@@ -84,12 +89,6 @@ const std::wstring& template_folder()
        return ftemplate;\r
 }\r
 \r
-const std::wstring& template_host()\r
-{\r
-       check_is_configured();\r
-       return ftemplate_host;\r
-}\r
-\r
 const std::wstring& data_folder()\r
 {\r
        check_is_configured();\r
@@ -98,7 +97,7 @@ const std::wstring& data_folder()
 \r
 const std::wstring& version()\r
 {\r
-       static std::wstring ver = std::wstring(L"") + CASPAR_GEN + L"." + CASPAR_MAYOR + L"." + CASPAR_MINOR + L"." + CASPAR_REV + L" ALPHA";\r
+       static std::wstring ver = std::wstring(L"") + CASPAR_GEN + L"." + CASPAR_MAYOR + L"." + CASPAR_MINOR + L"." + CASPAR_REV + L" " + CASPAR_TAG;\r
        return ver;\r
 }\r
 \r