aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/Paragraphs.cpp
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2017-04-08 16:26:26 -0700
committerRobert Schumacher <roschuma@microsoft.com>2017-04-08 16:26:26 -0700
commitc434dc99868989ca55aef5e445ac6a0a4c3430f7 (patch)
treeacfe66565a39a364b541013671ae786f2b5f7de4 /toolsrc/src/Paragraphs.cpp
parent19123677d111143dcbe0b168f4af90771be302cb (diff)
downloadvcpkg-c434dc99868989ca55aef5e445ac6a0a4c3430f7.tar.gz
vcpkg-c434dc99868989ca55aef5e445ac6a0a4c3430f7.zip
[vcpkg] Initial addition of Filesystem abstraction to enable testing.
Diffstat (limited to 'toolsrc/src/Paragraphs.cpp')
-rw-r--r--toolsrc/src/Paragraphs.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/toolsrc/src/Paragraphs.cpp b/toolsrc/src/Paragraphs.cpp
index 010da6700..e94478041 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(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(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(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,13 @@ namespace vcpkg::Paragraphs
return pghs.error_code();
}
- std::vector<SourceParagraph> load_all_ports(const fs::path& ports_dir)
+ std::vector<SourceParagraph> load_all_ports(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)
{
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));