-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.cpp
More file actions
55 lines (43 loc) · 1.22 KB
/
config.cpp
File metadata and controls
55 lines (43 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "config.h"
using namespace std;
Config::Config() : Logger("Config")
{
}
Config::~Config()
{
}
bool Config::load(string base)
{
m_containerBase = base;
string configpath = m_containerBase + "/config.yaml";
log("load: configpath=%s", configpath.c_str());
m_config = YAML::LoadFile(configpath.c_str());
if (!m_config)
{
error("load: Failed to load config!");
return false;
}
return true;
}
vector<pair<string, string> > Config::getMounts()
{
vector<pair<string, string> > mounts;
YAML::Node fileSystemNode = m_config["filesystem"];
if (fileSystemNode)
{
YAML::Node mountsNode = fileSystemNode["mounts"];
YAML::const_iterator mountIt;
for (mountIt = mountsNode.begin(); mountIt != mountsNode.end(); ++mountIt)
{
string mount = mountIt->first.as<std::string>();
string dest = mountIt->second.as<std::string>();
if (dest.length() > 0 && dest.at(0) != '/')
{
dest = m_containerBase + "/" + dest;
}
mounts.push_back(make_pair(mount, dest));
log("getMounts: mount: %s -> %s", mount.c_str(), dest.c_str());
}
}
return mounts;
}