diff options
| author | Robert Schumacher <roschuma@microsoft.com> | 2017-04-08 16:26:26 -0700 |
|---|---|---|
| committer | Robert Schumacher <roschuma@microsoft.com> | 2017-04-08 16:26:26 -0700 |
| commit | c434dc99868989ca55aef5e445ac6a0a4c3430f7 (patch) | |
| tree | acfe66565a39a364b541013671ae786f2b5f7de4 /toolsrc/include | |
| parent | 19123677d111143dcbe0b168f4af90771be302cb (diff) | |
| download | vcpkg-c434dc99868989ca55aef5e445ac6a0a4c3430f7.tar.gz vcpkg-c434dc99868989ca55aef5e445ac6a0a4c3430f7.zip | |
[vcpkg] Initial addition of Filesystem abstraction to enable testing.
Diffstat (limited to 'toolsrc/include')
| -rw-r--r-- | toolsrc/include/Paragraphs.h | 8 | ||||
| -rw-r--r-- | toolsrc/include/PostBuildLint_BuildInfo.h | 3 | ||||
| -rw-r--r-- | toolsrc/include/VcpkgPaths.h | 3 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_Files.h | 8 |
4 files changed, 16 insertions, 6 deletions
diff --git a/toolsrc/include/Paragraphs.h b/toolsrc/include/Paragraphs.h index 610ebbad6..cdd35e425 100644 --- a/toolsrc/include/Paragraphs.h +++ b/toolsrc/include/Paragraphs.h @@ -11,16 +11,16 @@ namespace vcpkg::Paragraphs { using ParagraphDataMap = std::unordered_map<std::string, std::string>; - Expected<ParagraphDataMap> get_single_paragraph(const fs::path& control_path); - Expected<std::vector<ParagraphDataMap>> get_paragraphs(const fs::path& control_path); + Expected<ParagraphDataMap> get_single_paragraph(Files::Filesystem& fs, const fs::path& control_path); + Expected<std::vector<ParagraphDataMap>> get_paragraphs(Files::Filesystem& fs, const fs::path& control_path); Expected<ParagraphDataMap> parse_single_paragraph(const std::string& str); Expected<std::vector<ParagraphDataMap>> parse_paragraphs(const std::string& str); - Expected<SourceParagraph> try_load_port(const fs::path& control_path); + Expected<SourceParagraph> try_load_port(Files::Filesystem& fs, const fs::path& control_path); Expected<BinaryParagraph> try_load_cached_package(const VcpkgPaths& paths, const PackageSpec& spec); - 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::map<std::string, VersionT> extract_port_names_and_versions(const std::vector<SourceParagraph>& source_paragraphs); } diff --git a/toolsrc/include/PostBuildLint_BuildInfo.h b/toolsrc/include/PostBuildLint_BuildInfo.h index 8bac18861..c54ea0fa5 100644 --- a/toolsrc/include/PostBuildLint_BuildInfo.h +++ b/toolsrc/include/PostBuildLint_BuildInfo.h @@ -1,6 +1,7 @@ #pragma once #include "filesystem_fs.h" +#include "vcpkg_Files.h" #include "PostBuildLint_BuildPolicies.h" #include "OptBool.h" #include "PostBuildLint_LinkageType.h" @@ -17,5 +18,5 @@ namespace vcpkg::PostBuildLint std::map<BuildPolicies::Type, OptBoolT> policies; }; - BuildInfo read_build_info(const fs::path& filepath); + BuildInfo read_build_info(Files::Filesystem& fs, const fs::path& filepath); } diff --git a/toolsrc/include/VcpkgPaths.h b/toolsrc/include/VcpkgPaths.h index 880b33b98..fdc4ad235 100644 --- a/toolsrc/include/VcpkgPaths.h +++ b/toolsrc/include/VcpkgPaths.h @@ -4,6 +4,7 @@ #include "PackageSpec.h" #include "BinaryParagraph.h" #include "Lazy.h" +#include "vcpkg_Files.h" namespace vcpkg { @@ -49,6 +50,8 @@ namespace vcpkg const fs::path& get_nuget_exe() const; const Toolset& get_toolset() const; + Files::Filesystem& get_filesystem() const; + private: Lazy<fs::path> cmake_exe; Lazy<fs::path> git_exe; diff --git a/toolsrc/include/vcpkg_Files.h b/toolsrc/include/vcpkg_Files.h index c1cf5b371..a114354bc 100644 --- a/toolsrc/include/vcpkg_Files.h +++ b/toolsrc/include/vcpkg_Files.h @@ -6,11 +6,17 @@ namespace vcpkg::Files { + __interface Filesystem + { + virtual Expected<std::string> read_contents(const fs::path& file_path) noexcept = 0; + }; + + Filesystem& get_real_filesystem(); + static const char* FILESYSTEM_INVALID_CHARACTERS = R"(\/:*?"<>|)"; bool has_invalid_chars_for_filesystem(const std::string& s); - Expected<std::string> read_contents(const fs::path& file_path) noexcept; Expected<std::vector<std::string>> read_all_lines(const fs::path& file_path); |
