[vcpkg] Avoid using s::status_known() -- it does not do what you think it does
MODIFY
include/vcpkg/base/files.h
include/vcpkg/base/files.h
@@ -14,6 +14,7 @@ namespace fs
using stdfs::copy_options;
using stdfs::file_status;
+ using stdfs::file_type;
using stdfs::path;
using stdfs::u8path;

MODIFY
src/vcpkg/install.cpp
src/vcpkg/install.cpp
@@ -69,7 +69,7 @@ namespace vcpkg::Install
continue;
}
- const std::string filename = file.filename().generic_string();
+ const std::string filename = file.filename().u8string();
if (fs::is_regular_file(status) && (Strings::case_insensitive_ascii_equals(filename.c_str(), "CONTROL") ||
Strings::case_insensitive_ascii_equals(filename.c_str(), "BUILD_INFO")))
{
@@ -80,7 +80,9 @@ namespace vcpkg::Install
const std::string suffix = file.generic_u8string().substr(prefix_length + 1);
const fs::path target = destination / suffix;
- if (fs::is_directory(status))
+ switch (status.type())
+ {
+ case fs::file_type::directory:
{
fs.create_directory(target, ec);
if (ec)
@@ -90,10 +92,9 @@ namespace vcpkg::Install
// Trailing backslash for directories
output.push_back(Strings::format(R"(%s/%s/)", destination_subdirectory, suffix));
- continue;
+ break;
}
-
- if (fs::is_regular_file(status))
+ case fs::file_type::regular:
{
if (fs.exists(target))
{
@@ -108,16 +109,12 @@ namespace vcpkg::Install
System::println(System::Color::error, "failed: %s: %s", target.u8string(), ec.message());
}
output.push_back(Strings::format(R"(%s/%s)", destination_subdirectory, suffix));
- continue;
- }
-
- if (!fs::status_known(status))
- {
- System::println(System::Color::error, "failed: %s: unknown status", file.u8string());
- continue;
+ break;
}
-
+ default:
System::println(System::Color::error, "failed: %s: cannot handle file type", file.u8string());
+ break;
+ }
}
std::sort(output.begin(), output.end());

[vcpkg] Avoid using s::status_known() -- it does not do what you think it does