| 507 | } |
| 508 | |
| 509 | Errata |
| 510 | Cache::loadSpanConfig(swoc::file::path const &path) |
| 511 | { |
| 512 | static const swoc::TextView TAG_ID("id"); |
| 513 | static const swoc::TextView TAG_VOL("volume"); |
| 514 | |
| 515 | Errata zret; |
| 516 | std::error_code ec; |
| 517 | std::string load_content = swoc::file::load(path, ec); |
| 518 | if (ec.value() == 0) { |
| 519 | swoc::TextView content(load_content); |
| 520 | while (content) { |
| 521 | swoc::TextView line = content.take_prefix_at('\n'); |
| 522 | line.ltrim_if(&isspace); |
| 523 | if (line.empty() || '#' == *line) { |
| 524 | continue; |
| 525 | } |
| 526 | swoc::TextView localpath = line.take_prefix_if(&isspace); |
| 527 | if (localpath) { |
| 528 | // After this the line is [size] [id=string] [volume=#] |
| 529 | while (line) { |
| 530 | swoc::TextView value(line.take_prefix_if(&isspace)); |
| 531 | if (value) { |
| 532 | swoc::TextView tag(value.take_prefix_at('=')); |
| 533 | if (!tag) { // must be the size |
| 534 | } else if (0 == strcasecmp(tag, TAG_ID)) { |
| 535 | } else if (0 == strcasecmp(tag, TAG_VOL)) { |
| 536 | swoc::TextView text; |
| 537 | auto n = swoc::svtoi(value, &text); |
| 538 | if (text == value && 0 < n && n < 256) { |
| 539 | } else { |
| 540 | zret.note("Invalid volume index '{}'", value); |
| 541 | } |
| 542 | } |
| 543 | } |
| 544 | } |
| 545 | zret = this->loadSpan(swoc::file::path(localpath)); |
| 546 | } |
| 547 | } |
| 548 | } else { |
| 549 | zret = Errata(make_errno_code(EBADF), "Unable to load {}", path); |
| 550 | } |
| 551 | return zret; |
| 552 | } |
| 553 | |
| 554 | Errata |
| 555 | Cache::loadURLs(swoc::file::path const &path) |
no test coverage detected