MCPcopy Create free account
hub / github.com/apache/kvrocks / Load

Method Load

utils/kvrocks2redis/config.cc:118–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116}
117
118Status Config::Load(std::string path) {
119 path_ = std::move(path);
120 std::ifstream file(path_);
121 if (!file.is_open()) {
122 return {Status::NotOK, fmt::format("failed to open file '{}': {}", path_, strerror(errno))};
123 }
124
125 std::string line;
126 int line_num = 1;
127 while (file.good() && std::getline(file, line)) {
128 Status s = parseConfigFromString(line);
129 if (!s.IsOK()) {
130 return s.Prefixed(fmt::format("at line #L{}", line_num));
131 }
132
133 line_num++;
134 }
135
136 auto s = rocksdb::Env::Default()->FileExists(data_dir);
137 if (!s.ok()) {
138 if (s.IsNotFound()) {
139 return {Status::NotOK, fmt::format("the specified Kvrocks working directory '{}' doesn't exist", data_dir)};
140 }
141 return {Status::NotOK, s.ToString()};
142 }
143
144 s = rocksdb::Env::Default()->FileExists(output_dir);
145 if (!s.ok()) {
146 if (s.IsNotFound()) {
147 return {Status::NotOK,
148 fmt::format("the specified directory '{}' for intermediate files doesn't exist", output_dir)};
149 }
150 return {Status::NotOK, s.ToString()};
151 }
152
153 return Status::OK();
154}
155
156} // namespace kvrocks2redis

Callers 1

mainFunction · 0.45

Calls 4

FileExistsMethod · 0.80
IsOKMethod · 0.45
PrefixedMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected