\r
#include "../version.h"\r
\r
-#include "exception\exceptions.h"\r
-#include "utility/string.h"\r
+#include "except.h"\r
+#include "log.h"\r
+#include "string.h"\r
\r
#include <boost/property_tree/ptree.hpp>\r
#include <boost/property_tree/xml_parser.hpp>\r
#include <iostream>\r
\r
namespace caspar { namespace env {\r
-\r
-using namespace boost::filesystem2;\r
-\r
+ \r
std::wstring media;\r
std::wstring log;\r
std::wstring ftemplate;\r
void check_is_configured()\r
{\r
if(pt.empty())\r
- BOOST_THROW_EXCEPTION(invalid_operation() << msg_info("Enviroment properties has not been configured"));\r
+ BOOST_THROW_EXCEPTION(invalid_operation() << msg_info(L"Enviroment properties has not been configured"));\r
}\r
\r
void configure(const std::wstring& filename)\r
{\r
try\r
{\r
- auto initialPath = boost::filesystem::initial_path<boost::filesystem2::wpath>().file_string();\r
+ auto initialPath = boost::filesystem3::initial_path().wstring();\r
\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 = u16(paths.get(L"media-path", initialPath + L"\\media\\"));\r
- log = u16(paths.get(L"log-path", initialPath + L"\\log\\"));\r
- ftemplate = complete(wpath(u16(paths.get(L"template-path", initialPath + L"\\template\\")))).string(); \r
- data = u16(paths.get(L"data-path", initialPath + L"\\data\\"));\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
- std::wcout << L" ### Invalid configuration file. ###";\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
}\r
\r
const std::wstring& media_folder()\r
return data;\r
}\r
\r
+#define QUOTE(str) #str\r
+#define EXPAND_AND_QUOTE(str) QUOTE(str)\r
+\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" " + CASPAR_TAG;\r
+ static std::wstring ver = u16(\r
+ EXPAND_AND_QUOTE(CASPAR_GEN) "." \r
+ EXPAND_AND_QUOTE(CASPAR_MAYOR) "." \r
+ EXPAND_AND_QUOTE(CASPAR_MINOR) "." \r
+ EXPAND_AND_QUOTE(CASPAR_REV) " " \r
+ CASPAR_TAG);\r
return ver;\r
}\r
\r