- 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
+ 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 = paths.get(L"media-path", initialPath + L"\\media\\");\r
+ log = paths.get(L"log-path", initialPath + L"\\log\\");\r
+ ftemplate = boost::filesystem3::complete(paths.get(L"template-path", initialPath + L"\\template\\")).wstring(); \r
+ data = paths.get(L"data-path", initialPath + L"\\data\\");\r
+\r
+ try\r
+ {\r
+ for(auto it = boost::filesystem::directory_iterator(initialPath); it != boost::filesystem::directory_iterator(); ++it)\r
+ {\r
+ if(it->path().wstring().find(L".fth") != std::wstring::npos) \r
+ {\r
+ auto from_path = *it;\r
+ auto to_path = boost::filesystem::path(ftemplate + L"/" + it->path().wstring());\r
+ \r
+ if(boost::filesystem::exists(to_path))\r
+ boost::filesystem::remove(to_path);\r
+\r
+ boost::filesystem::copy_file(from_path, to_path);\r
+ } \r
+ }\r
+ }\r
+ catch(...)\r
+ {\r
+ CASPAR_LOG_CURRENT_EXCEPTION();\r
+ CASPAR_LOG(error) << L"Failed to copy template-hosts from initial-path to template-path.";\r
+ }\r
+ }\r
+ catch(...)\r
+ {\r
+ CASPAR_LOG(error) << L" ### Invalid configuration file. ###";\r
+ throw;\r
+ }\r
+\r
+ try\r
+ {\r
+ auto media_path = boost::filesystem::path(media);\r
+ if(!boost::filesystem::exists(media_path))\r
+ boost::filesystem::create_directory(media_path);\r
+ \r
+ auto log_path = boost::filesystem::path(log);\r
+ if(!boost::filesystem::exists(log_path))\r
+ boost::filesystem::create_directory(log_path);\r
+ \r
+ auto template_path = boost::filesystem::path(ftemplate);\r
+ if(!boost::filesystem::exists(template_path))\r
+ boost::filesystem::create_directory(template_path);\r
+ \r
+ auto data_path = boost::filesystem::path(data);\r
+ if(!boost::filesystem::exists(data_path))\r
+ boost::filesystem::create_directory(data_path);\r
+ }\r
+ catch(...)\r
+ {\r
+ CASPAR_LOG_CURRENT_EXCEPTION();\r
+ CASPAR_LOG(error) << L"Failed to create configured directories.";\r
+ }\r