diff options
| author | Robert Schumacher <roschuma@microsoft.com> | 2017-04-14 16:07:54 -0700 |
|---|---|---|
| committer | Robert Schumacher <roschuma@microsoft.com> | 2017-04-14 16:07:54 -0700 |
| commit | 20397fc845fac398a1aca2ee17ce5b932fc1a83b (patch) | |
| tree | 51235bc2602a81a89da9605272a37ca4fc1765a8 /toolsrc/src/Paragraphs.cpp | |
| parent | 8183671a492aa21ec20780a77f923848b0aeca41 (diff) | |
| parent | 1c08a42091cb0addd1e0c1daf27d24bf4e9d237f (diff) | |
| download | vcpkg-20397fc845fac398a1aca2ee17ce5b932fc1a83b.tar.gz vcpkg-20397fc845fac398a1aca2ee17ce5b932fc1a83b.zip | |
Merge branch 'dev/roschuma/fs-testing'
Diffstat (limited to 'toolsrc/src/Paragraphs.cpp')
| -rw-r--r-- | toolsrc/src/Paragraphs.cpp | 21 |
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)); |
