| 323 | } |
| 324 | |
| 325 | void Parser::ParseFile(std::string path, std::string dir) { |
| 326 | fassert(path != "", "Empty path"); |
| 327 | std::ifstream f(path); |
| 328 | if (dir != "") { |
| 329 | fassert( |
| 330 | util::IsDir(dir), |
| 331 | util::Format( |
| 332 | "Not a directory '{}' specified to look for file '{}'", dir, path)); |
| 333 | auto path2 = util::Join(dir, path); |
| 334 | if (!f.good() && path[0] != '/') { |
| 335 | f.open(path2); |
| 336 | fassert( |
| 337 | f.good(), util::Format("Can't open file '{}' or '{}'", path, path2)); |
| 338 | } |
| 339 | path = path2; |
| 340 | } |
| 341 | fassert(f.good(), util::Format("Can't open file '{}'", path)); |
| 342 | |
| 343 | int line = 0; |
| 344 | while (f) { |
| 345 | const std::pair<std::string, int> p = ReadMultiline(f); |
| 346 | line += p.second; |
| 347 | imp->Cmd(p.first, path, line); |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | template <class T> |
| 352 | void Parser::PrintMap(const Vars::Map<T>& m, std::ostream& out) { |