aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/commands_cache.cpp
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2017-03-24 10:46:49 -0700
committerAlexander Karatarakis <alkarata@microsoft.com>2017-03-27 12:43:14 -0700
commitd2bab3c370fca9fa5216d97495810faaeeaebc2d (patch)
tree205fd2130c93e9fe40975a271dd11381b562fead /toolsrc/src/commands_cache.cpp
parent90bb4a2eeb316fbc5055d507044229cbc8bc5337 (diff)
downloadvcpkg-d2bab3c370fca9fa5216d97495810faaeeaebc2d.tar.gz
vcpkg-d2bab3c370fca9fa5216d97495810faaeeaebc2d.zip
Rework Paragraph parsing error handling. Add single paragraph functions
Diffstat (limited to 'toolsrc/src/commands_cache.cpp')
-rw-r--r--toolsrc/src/commands_cache.cpp19
1 files changed, 4 insertions, 15 deletions
diff --git a/toolsrc/src/commands_cache.cpp b/toolsrc/src/commands_cache.cpp
index 417799abb..6504c8c4d 100644
--- a/toolsrc/src/commands_cache.cpp
+++ b/toolsrc/src/commands_cache.cpp
@@ -13,22 +13,11 @@ namespace vcpkg::Commands::Cache
for (auto it = fs::directory_iterator(paths.packages); it != fs::directory_iterator(); ++it)
{
const fs::path& path = it->path();
-
- try
- {
- auto file_contents = Files::read_contents(path / "CONTROL");
- if (auto text = file_contents.get())
- {
- auto pghs = Paragraphs::parse_paragraphs(*text);
- if (pghs.size() != 1)
- continue;
-
- const BinaryParagraph binary_paragraph = BinaryParagraph(pghs[0]);
- output.push_back(binary_paragraph);
- }
- }
- catch (std::runtime_error const&)
+ const expected<std::unordered_map<std::string, std::string>> pghs = Paragraphs::get_single_paragraph(path / "CONTROL");
+ if (auto p = pghs.get())
{
+ const BinaryParagraph binary_paragraph = BinaryParagraph(*p);
+ output.push_back(binary_paragraph);
}
}