2 * copyright (c) 2010 Sveriges Television AB <info@casparcg.com>
\r
4 * This file is part of CasparCG.
\r
6 * CasparCG is free software: you can redistribute it and/or modify
\r
7 * it under the terms of the GNU General Public License as published by
\r
8 * the Free Software Foundation, either version 3 of the License, or
\r
9 * (at your option) any later version.
\r
11 * CasparCG is distributed in the hope that it will be useful,
\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License
\r
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
\r
24 #include "../version.h"
\r
26 #include "exception\exceptions.h"
\r
27 #include "utility/string.h"
\r
29 #include <boost/property_tree/ptree.hpp>
\r
30 #include <boost/property_tree/xml_parser.hpp>
\r
31 #include <boost/filesystem.hpp>
\r
32 #include <boost/thread/once.hpp>
\r
34 #include <functional>
\r
37 namespace caspar { namespace env {
\r
39 using namespace boost::filesystem2;
\r
43 std::wstring ftemplate;
\r
45 boost::property_tree::ptree pt;
\r
47 void check_is_configured()
\r
50 BOOST_THROW_EXCEPTION(invalid_operation() << msg_info("Enviroment properties has not been configured"));
\r
53 void configure(const std::string& filename)
\r
57 std::string initialPath = boost::filesystem::initial_path().file_string();
\r
59 boost::property_tree::read_xml(initialPath + "\\" + filename, pt);
\r
61 auto paths = pt.get_child("configuration.paths");
\r
62 media = widen(paths.get("media-path", initialPath + "\\media\\"));
\r
63 log = widen(paths.get("log-path", initialPath + "\\log\\"));
\r
64 ftemplate = complete(wpath(widen(paths.get("template-path", initialPath + "\\template\\")))).string();
\r
65 data = widen(paths.get("data-path", initialPath + "\\data\\"));
\r
69 std::wcout << L" ### Invalid configuration file. ###";
\r
74 const std::wstring& media_folder()
\r
76 check_is_configured();
\r
80 const std::wstring& log_folder()
\r
82 check_is_configured();
\r
86 const std::wstring& template_folder()
\r
88 check_is_configured();
\r
92 const std::wstring& data_folder()
\r
94 check_is_configured();
\r
98 const std::wstring& version()
\r
100 static std::wstring ver = std::wstring(L"") + CASPAR_GEN + L"." + CASPAR_MAYOR + L"." + CASPAR_MINOR + L"." + CASPAR_REV + L" " + CASPAR_TAG;
\r
104 const boost::property_tree::ptree& properties()
\r
106 check_is_configured();
\r