]> git.sesse.net Git - casparcg/blobdiff - common/env.cpp
2.0.2: - Updated to use std::wstring more consistently.
[casparcg] / common / env.cpp
index b584474e86ba0553f87c3f950b7b0c3519a68fad..3616397e46e0c04d97973dbf702479dbe059a862 100644 (file)
@@ -44,7 +44,7 @@ std::wstring media;
 std::wstring log;\r
 std::wstring ftemplate;\r
 std::wstring data;\r
-boost::property_tree::ptree pt;\r
+boost::property_tree::wptree pt;\r
 \r
 void check_is_configured()\r
 {\r
@@ -52,19 +52,20 @@ void check_is_configured()
                BOOST_THROW_EXCEPTION(invalid_operation() << msg_info("Enviroment properties has not been configured"));\r
 }\r
 \r
-void configure(const std::string& filename)\r
+void configure(const std::wstring& filename)\r
 {\r
        try\r
        {\r
-               std::string initialPath = boost::filesystem::initial_path().file_string();\r
+               auto initialPath = boost::filesystem::initial_path<boost::filesystem2::wpath>().file_string();\r
        \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
+               std::wifstream file(initialPath + L"\\" + filename);\r
+               boost::property_tree::read_xml(file, pt, boost::property_tree::xml_parser::trim_whitespace | boost::property_tree::xml_parser::no_comments);\r
+\r
+               auto paths = pt.get_child(L"configuration.paths");\r
+               media = widen(paths.get(L"media-path", initialPath + L"\\media\\"));\r
+               log = widen(paths.get(L"log-path", initialPath + L"\\log\\"));\r
+               ftemplate = complete(wpath(widen(paths.get(L"template-path", initialPath + L"\\template\\")))).string();                \r
+               data = widen(paths.get(L"data-path", initialPath + L"\\data\\"));\r
        }\r
        catch(...)\r
        {\r
@@ -103,7 +104,7 @@ const std::wstring& version()
        return ver;\r
 }\r
 \r
-const boost::property_tree::ptree& properties()\r
+const boost::property_tree::wptree& properties()\r
 {\r
        check_is_configured();\r
        return pt;\r