/*\r
-* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
+* Copyright 2013 Sveriges Television AB http://casparcg.com/\r
*\r
* This file is part of CasparCG (www.casparcg.com).\r
*\r
\r
#include "../version.h"\r
\r
-#include "exception\exceptions.h"\r
+#include "exception/exceptions.h"\r
+#include "log/log.h"\r
#include "utility/string.h"\r
\r
#include <boost/property_tree/ptree.hpp>\r
std::wstring log;\r
std::wstring ftemplate;\r
std::wstring data;\r
+std::wstring thumbnails;\r
boost::property_tree::wptree pt;\r
\r
void check_is_configured()\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
+ thumbnails = widen(paths.get(L"thumbnails-path", initialPath + L"\\thumbnails\\"));\r
+\r
+ //Make sure that all paths have a trailing backslash\r
+ if(media.at(media.length()-1) != L'\\')\r
+ media.append(L"\\");\r
+ if(log.at(log.length()-1) != L'\\')\r
+ log.append(L"\\");\r
+ if(ftemplate.at(ftemplate.length()-1) != L'\\')\r
+ ftemplate.append(L"\\");\r
+ if(data.at(data.length()-1) != L'\\')\r
+ data.append(L"\\");\r
+ if(thumbnails.at(thumbnails.length()-1) != L'\\')\r
+ thumbnails.append(L"\\");\r
+\r
+ try\r
+ {\r
+ for(auto it = boost::filesystem2::wdirectory_iterator(initialPath); it != boost::filesystem2::wdirectory_iterator(); ++it)\r
+ {\r
+ if(it->filename().find(L".fth") != std::wstring::npos) \r
+ {\r
+ auto from_path = *it;\r
+ auto to_path = boost::filesystem2::wpath(ftemplate + L"/" + it->filename());\r
+ \r
+ if(boost::filesystem2::exists(to_path))\r
+ boost::filesystem2::remove(to_path);\r
+\r
+ boost::filesystem2::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
throw;\r
}\r
+\r
+ try\r
+ {\r
+ auto media_path = boost::filesystem::wpath(media);\r
+ if(!boost::filesystem::exists(media_path))\r
+ boost::filesystem::create_directory(media_path);\r
+ \r
+ auto log_path = boost::filesystem::wpath(log);\r
+ if(!boost::filesystem::exists(log_path))\r
+ boost::filesystem::create_directory(log_path);\r
+ \r
+ auto template_path = boost::filesystem::wpath(ftemplate);\r
+ if(!boost::filesystem::exists(template_path))\r
+ boost::filesystem::create_directory(template_path);\r
+ \r
+ auto data_path = boost::filesystem::wpath(data);\r
+ if(!boost::filesystem::exists(data_path))\r
+ boost::filesystem::create_directory(data_path);\r
+ \r
+ auto thumbnails_path = boost::filesystem::wpath(thumbnails);\r
+ if(!boost::filesystem::exists(thumbnails_path))\r
+ boost::filesystem::create_directory(thumbnails_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
+const std::wstring& thumbnails_folder()\r
+{\r
+ check_is_configured();\r
+ return thumbnails;\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 = widen(\r
+ EXPAND_AND_QUOTE(CASPAR_GEN) "." \r
+ EXPAND_AND_QUOTE(CASPAR_MAYOR) "." \r
+ EXPAND_AND_QUOTE(CASPAR_MINOR) "." \r
+ CASPAR_REV " " \r
+ CASPAR_TAG);\r
return ver;\r
}\r
\r