]> git.sesse.net Git - casparcg/blob - common/env.cpp
ยค412
[casparcg] / common / env.cpp
1 #include "stdafx.h"\r
2 \r
3 #include "env.h"\r
4 \r
5 #include "../version.h"\r
6 \r
7 #include "utility/string.h"\r
8 \r
9 #include <boost/property_tree/ptree.hpp>\r
10 #include <boost/property_tree/xml_parser.hpp>\r
11 #include <boost/filesystem.hpp>\r
12 #include <boost/thread/once.hpp>\r
13 \r
14 #include <functional>\r
15 \r
16 namespace caspar\r
17 {\r
18 \r
19 std::wstring media;\r
20 std::wstring log;\r
21 std::wstring ftemplate;\r
22 std::wstring ftemplate_host;\r
23 std::wstring data;\r
24 boost::property_tree::ptree pt;\r
25 \r
26 void env::initialize(const std::string& filename)\r
27 {\r
28         std::string initialPath = boost::filesystem::initial_path().file_string();\r
29         \r
30         boost::property_tree::read_xml(initialPath + "\\" + filename, pt);\r
31 \r
32         auto paths = pt.get_child("configuration.paths");\r
33         media = widen(paths.get("media-path", initialPath + "\\media\\"));\r
34         log = widen(paths.get("log-path", initialPath + "\\log\\"));\r
35         ftemplate = widen(paths.get("template-path", initialPath + "\\template\\"));\r
36         ftemplate_host = widen(paths.get("template-host", "cg.fth"));\r
37         data = widen(paths.get("data-path", initialPath + "\\data\\"));\r
38 }\r
39         \r
40 const std::wstring& env::media_folder()\r
41 {\r
42         return media;\r
43 }\r
44 \r
45 const std::wstring& env::log_folder()\r
46 {\r
47         return log;\r
48 }\r
49 \r
50 const std::wstring& env::template_folder()\r
51 {\r
52         return ftemplate;\r
53 }\r
54 \r
55 const std::wstring& env::template_host()\r
56 {\r
57         return ftemplate_host;\r
58 }\r
59 \r
60 \r
61 const std::wstring& env::data_folder()\r
62 {\r
63         return data;\r
64 }\r
65 \r
66 const std::wstring& env::version()\r
67 {\r
68         static std::wstring ver = std::wstring(L"") + CASPAR_GEN + L"." + CASPAR_MAYOR + L"." + CASPAR_MINOR + L"." + CASPAR_REV;\r
69         return ver;\r
70 }\r
71 \r
72 const boost::property_tree::ptree& env::properties()\r
73 {\r
74         return pt;\r
75 }\r
76 \r
77 }