From 62cde6598ddbf30f6872895aaf9715fc87f7b7aa Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 30 Aug 2017 22:42:43 -0700 Subject: Move function to Files::find_from_PATH() --- toolsrc/src/VcpkgPaths.cpp | 20 ++++---------------- toolsrc/src/vcpkg_Files.cpp | 13 +++++++++++++ 2 files changed, 17 insertions(+), 16 deletions(-) (limited to 'toolsrc/src') diff --git a/toolsrc/src/VcpkgPaths.cpp b/toolsrc/src/VcpkgPaths.cpp index ef9209b78..865f2ce44 100644 --- a/toolsrc/src/VcpkgPaths.cpp +++ b/toolsrc/src/VcpkgPaths.cpp @@ -13,7 +13,7 @@ namespace vcpkg static std::string WORKAROUND_ISSUE_1712(const std::string& line) { auto colon_pos = line.find(':'); - if (colon_pos != std::string::npos && colon_pos > 0) + if (colon_pos != std::string::npos && colon_pos > 1) { return line.substr(colon_pos - 1); } @@ -68,18 +68,6 @@ namespace vcpkg return nullopt; } - static std::vector find_from_PATH(const std::wstring& name) - { - const std::wstring cmd = Strings::wformat(L"where.exe %s", name); - auto out = System::cmd_execute_and_capture_output(cmd); - if (out.exit_code != 0) - { - return {}; - } - - return Util::fmap(Strings::split(out.output, "\n"), [](auto&& s) { return fs::path(s); }); - } - static fs::path fetch_dependency(const fs::path& scripts_folder, const std::wstring& tool_name, const fs::path& expected_downloaded_path, @@ -122,7 +110,7 @@ namespace vcpkg static const std::wstring version_check_arguments = L"--version"; const fs::path downloaded_copy = downloads_folder / "cmake-3.9.1-win32-x86" / "bin" / "cmake.exe"; - const std::vector from_path = find_from_PATH(L"cmake"); + const std::vector from_path = Files::find_from_PATH(L"cmake"); std::vector candidate_paths; candidate_paths.push_back(downloaded_copy); @@ -146,7 +134,7 @@ namespace vcpkg static const std::wstring version_check_arguments = Strings::WEMPTY; const fs::path downloaded_copy = downloads_folder / "nuget-4.1.0" / "nuget.exe"; - const std::vector from_path = find_from_PATH(L"nuget"); + const std::vector from_path = Files::find_from_PATH(L"nuget"); std::vector candidate_paths; candidate_paths.push_back(downloaded_copy); @@ -167,7 +155,7 @@ namespace vcpkg static const std::wstring version_check_arguments = L"--version"; const fs::path downloaded_copy = downloads_folder / "MinGit-2.14.1-32-bit" / "cmd" / "git.exe"; - const std::vector from_path = find_from_PATH(L"git"); + const std::vector from_path = Files::find_from_PATH(L"git"); std::vector candidate_paths; candidate_paths.push_back(downloaded_copy); diff --git a/toolsrc/src/vcpkg_Files.cpp b/toolsrc/src/vcpkg_Files.cpp index 24edb779f..ad1fcebc6 100644 --- a/toolsrc/src/vcpkg_Files.cpp +++ b/toolsrc/src/vcpkg_Files.cpp @@ -2,6 +2,7 @@ #include "vcpkg_Files.h" #include "vcpkg_System.h" +#include "vcpkg_Util.h" #include namespace vcpkg::Files @@ -193,4 +194,16 @@ namespace vcpkg::Files } System::println(); } + + std::vector find_from_PATH(const std::wstring& name) + { + const std::wstring cmd = Strings::wformat(L"where.exe %s", name); + auto out = System::cmd_execute_and_capture_output(cmd); + if (out.exit_code != 0) + { + return {}; + } + + return Util::fmap(Strings::split(out.output, "\n"), [](auto&& s) { return fs::path(s); }); + } } -- cgit v1.2.3