diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2017-02-27 15:13:13 -0800 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2017-02-27 15:13:13 -0800 |
| commit | 33952d2dd29208b0a28d3e058e33222ef454f04d (patch) | |
| tree | f200cba709e3d8cf1e84511690d1e21daadb5eaa /toolsrc/src/vcpkglib.cpp | |
| parent | eb07291f0c504d56e6def13cd730bd210f5e4c1e (diff) | |
| download | vcpkg-33952d2dd29208b0a28d3e058e33222ef454f04d.tar.gz vcpkg-33952d2dd29208b0a28d3e058e33222ef454f04d.zip | |
Introduce function: load_all_ports()
Diffstat (limited to 'toolsrc/src/vcpkglib.cpp')
| -rw-r--r-- | toolsrc/src/vcpkglib.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/toolsrc/src/vcpkglib.cpp b/toolsrc/src/vcpkglib.cpp index 0c71a4d88..d3356d68d 100644 --- a/toolsrc/src/vcpkglib.cpp +++ b/toolsrc/src/vcpkglib.cpp @@ -232,4 +232,24 @@ namespace vcpkg } return control_contents_maybe.error_code(); } + + std::vector<SourceParagraph> load_all_ports(const fs::path& ports_dir) + { + std::vector<SourceParagraph> output; + for (auto it = fs::directory_iterator(ports_dir); it != fs::directory_iterator(); ++it) + { + const fs::path& path = it->path(); + expected<SourceParagraph> source_paragraph = try_load_port(path); + if (auto srcpgh = source_paragraph.get()) + { + output.emplace_back(*srcpgh); + } + else + { + Checks::exit_with_message("Error loading port from %s: %s", path.generic_string(), source_paragraph.error_code().message()); + } + } + + return output; + } } |
