aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src
diff options
context:
space:
mode:
Diffstat (limited to 'toolsrc/src')
-rw-r--r--toolsrc/src/vcpkg.cpp4
-rw-r--r--toolsrc/src/vcpkg/base/files.cpp7
-rw-r--r--toolsrc/src/vcpkg/base/strings.cpp12
3 files changed, 11 insertions, 12 deletions
diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp
index 06c99e9a8..ac2eec876 100644
--- a/toolsrc/src/vcpkg.cpp
+++ b/toolsrc/src/vcpkg.cpp
@@ -70,7 +70,7 @@ static void inner(const VcpkgCmdArguments& args)
fs::path vcpkg_root_dir;
if (args.vcpkg_root_dir != nullptr)
{
- vcpkg_root_dir = fs::stdfs::absolute(Strings::to_utf16(*args.vcpkg_root_dir));
+ vcpkg_root_dir = fs::stdfs::absolute(fs::u8path(*args.vcpkg_root_dir));
}
else
{
@@ -94,6 +94,8 @@ static void inner(const VcpkgCmdArguments& args)
Checks::check_exit(VCPKG_LINE_INFO, !vcpkg_root_dir.empty(), "Error: Could not detect vcpkg-root.");
+ Debug::println("Using vcpkg-root: %s", vcpkg_root_dir.u8string());
+
auto default_vs_path = System::get_environment_variable("VCPKG_DEFAULT_VS_PATH").value_or("");
const Expected<VcpkgPaths> expected_paths = VcpkgPaths::create(vcpkg_root_dir, default_vs_path);
diff --git a/toolsrc/src/vcpkg/base/files.cpp b/toolsrc/src/vcpkg/base/files.cpp
index 1723b467e..0542af1e7 100644
--- a/toolsrc/src/vcpkg/base/files.cpp
+++ b/toolsrc/src/vcpkg/base/files.cpp
@@ -56,16 +56,17 @@ namespace vcpkg::Files
const std::string& filename) const override
{
fs::path current_dir = starting_dir;
- for (; !current_dir.empty(); current_dir = current_dir.parent_path())
+ fs::path unix_root = "/";
+ for (; !current_dir.empty() && current_dir != unix_root; current_dir = current_dir.parent_path())
{
const fs::path candidate = current_dir / filename;
if (exists(candidate))
{
- break;
+ return current_dir;
}
}
- return current_dir;
+ return fs::path();
}
virtual std::vector<fs::path> get_files_recursive(const fs::path& dir) const override
diff --git a/toolsrc/src/vcpkg/base/strings.cpp b/toolsrc/src/vcpkg/base/strings.cpp
index fbc33ca42..48dc5ed09 100644
--- a/toolsrc/src/vcpkg/base/strings.cpp
+++ b/toolsrc/src/vcpkg/base/strings.cpp
@@ -49,33 +49,29 @@ namespace vcpkg::Strings::details
namespace vcpkg::Strings
{
+#if defined(_WIN32)
std::wstring to_utf16(const CStringView& s)
{
-#if defined(_WIN32)
std::wstring output;
const size_t size = MultiByteToWideChar(CP_UTF8, 0, s.c_str(), -1, nullptr, 0);
if (size == 0) return output;
output.resize(size - 1);
MultiByteToWideChar(CP_UTF8, 0, s.c_str(), -1, output.data(), static_cast<int>(size) - 1);
return output;
-#else
- Checks::unreachable(VCPKG_LINE_INFO);
-#endif
}
+#endif
+#if defined(_WIN32)
std::string to_utf8(const wchar_t* w)
{
-#if defined(_WIN32)
std::string output;
const size_t size = WideCharToMultiByte(CP_UTF8, 0, w, -1, nullptr, 0, nullptr, nullptr);
if (size == 0) return output;
output.resize(size - 1);
WideCharToMultiByte(CP_UTF8, 0, w, -1, output.data(), static_cast<int>(size) - 1, nullptr, nullptr);
return output;
-#else
- Checks::unreachable(VCPKG_LINE_INFO);
-#endif
}
+#endif
std::string escape_string(const CStringView& s, char char_to_escape, char escape_char)
{