aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/Paragraphs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'toolsrc/src/Paragraphs.cpp')
-rw-r--r--toolsrc/src/Paragraphs.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/toolsrc/src/Paragraphs.cpp b/toolsrc/src/Paragraphs.cpp
index 010da6700..f14552169 100644
--- a/toolsrc/src/Paragraphs.cpp
+++ b/toolsrc/src/Paragraphs.cpp
@@ -172,9 +172,9 @@ namespace vcpkg::Paragraphs
}
};
- Expected<std::unordered_map<std::string, std::string>> get_single_paragraph(const fs::path& control_path)
+ Expected<std::unordered_map<std::string, std::string>> get_single_paragraph(const Files::Filesystem& fs, const fs::path& control_path)
{
- const Expected<std::string> contents = Files::read_contents(control_path);
+ const Expected<std::string> contents = fs.read_contents(control_path);
if (auto spgh = contents.get())
{
return parse_single_paragraph(*spgh);
@@ -183,9 +183,9 @@ namespace vcpkg::Paragraphs
return contents.error_code();
}
- Expected<std::vector<std::unordered_map<std::string, std::string>>> get_paragraphs(const fs::path& control_path)
+ Expected<std::vector<std::unordered_map<std::string, std::string>>> get_paragraphs(const Files::Filesystem& fs, const fs::path& control_path)
{
- const Expected<std::string> contents = Files::read_contents(control_path);
+ const Expected<std::string> contents = fs.read_contents(control_path);
if (auto spgh = contents.get())
{
return parse_paragraphs(*spgh);
@@ -211,9 +211,9 @@ namespace vcpkg::Paragraphs
return Parser(str.c_str(), str.c_str() + str.size()).get_paragraphs();
}
- Expected<SourceParagraph> try_load_port(const fs::path& path)
+ Expected<SourceParagraph> try_load_port(const Files::Filesystem& fs, const fs::path& path)
{
- Expected<std::unordered_map<std::string, std::string>> pghs = get_single_paragraph(path / "CONTROL");
+ Expected<std::unordered_map<std::string, std::string>> pghs = get_single_paragraph(fs, path / "CONTROL");
if (auto p = pghs.get())
{
return SourceParagraph(*p);
@@ -224,7 +224,7 @@ namespace vcpkg::Paragraphs
Expected<BinaryParagraph> try_load_cached_package(const VcpkgPaths& paths, const PackageSpec& spec)
{
- Expected<std::unordered_map<std::string, std::string>> pghs = get_single_paragraph(paths.package_dir(spec) / "CONTROL");
+ Expected<std::unordered_map<std::string, std::string>> pghs = get_single_paragraph(paths.get_filesystem(), paths.package_dir(spec) / "CONTROL");
if (auto p = pghs.get())
{
@@ -234,13 +234,12 @@ namespace vcpkg::Paragraphs
return pghs.error_code();
}
- std::vector<SourceParagraph> load_all_ports(const fs::path& ports_dir)
+ std::vector<SourceParagraph> load_all_ports(const Files::Filesystem& fs, const fs::path& ports_dir)
{
std::vector<SourceParagraph> output;
- for (auto it = fs::directory_iterator(ports_dir); it != fs::directory_iterator(); ++it)
+ for (auto&& path : fs.get_files_non_recursive(ports_dir))
{
- const fs::path& path = it->path();
- Expected<SourceParagraph> source_paragraph = try_load_port(path);
+ Expected<SourceParagraph> source_paragraph = try_load_port(fs, path);
if (auto srcpgh = source_paragraph.get())
{
output.emplace_back(std::move(*srcpgh));