| 598 | } |
| 599 | |
| 600 | std::vector<Path> CollectLayersPaths(const Path& directory) { |
| 601 | std::vector<Path> paths = CollectFilePaths(directory, "*json"); |
| 602 | |
| 603 | std::vector<Path> results; |
| 604 | for (std::size_t i = 0, n = paths.size(); i < n; ++i) { |
| 605 | const QJsonDocument& document = ::ParseJsonFile(paths[i].AbsolutePath().c_str()); |
| 606 | if (document.isNull() || document.isEmpty()) { |
| 607 | continue; |
| 608 | } |
| 609 | |
| 610 | const QJsonObject& json_root_object = document.object(); |
| 611 | if (json_root_object.value("file_format_version") == QJsonValue::Undefined) { |
| 612 | continue; // Not a layer JSON file |
| 613 | } |
| 614 | |
| 615 | if (json_root_object.value("layer") == QJsonValue::Undefined && json_root_object.value("layers") == QJsonValue::Undefined) { |
| 616 | continue; |
| 617 | } |
| 618 | |
| 619 | results.push_back(paths[i]); |
| 620 | } |
| 621 | |
| 622 | return results; |
| 623 | } |
| 624 | |
| 625 | std::vector<Path> CollectDriversPaths(const Path& directory) { |
| 626 | std::vector<Path> paths = CollectFilePaths(directory, "*json"); |
no test coverage detected