diff options
| author | Robert Schumacher <roschuma@microsoft.com> | 2018-02-16 15:40:22 -0800 |
|---|---|---|
| committer | Robert Schumacher <roschuma@microsoft.com> | 2018-02-16 15:40:22 -0800 |
| commit | 452c8ba1ff4c06e5cf7b2f2c4ff449eaefb83f79 (patch) | |
| tree | 9dd40ebd16afc6316aad31c8ad2ea566a22a0c60 /toolsrc | |
| parent | 72bc3647b61ad3e8df8d1e620daa7d919b5241d6 (diff) | |
| download | vcpkg-452c8ba1ff4c06e5cf7b2f2c4ff449eaefb83f79.tar.gz vcpkg-452c8ba1ff4c06e5cf7b2f2c4ff449eaefb83f79.zip | |
[vcpkg] Avoid using s::status_known() -- it does not do what you think it does
Diffstat (limited to 'toolsrc')
| -rw-r--r-- | toolsrc/include/vcpkg/base/files.h | 1 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/install.cpp | 61 |
2 files changed, 30 insertions, 32 deletions
diff --git a/toolsrc/include/vcpkg/base/files.h b/toolsrc/include/vcpkg/base/files.h index 51a12ceba..9bdc0aa4b 100644 --- a/toolsrc/include/vcpkg/base/files.h +++ b/toolsrc/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; diff --git a/toolsrc/src/vcpkg/install.cpp b/toolsrc/src/vcpkg/install.cpp index 595945d39..631b16c59 100644 --- a/toolsrc/src/vcpkg/install.cpp +++ b/toolsrc/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,44 +80,41 @@ 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()) { - fs.create_directory(target, ec); - if (ec) + case fs::file_type::directory: { - System::println(System::Color::error, "failed: %s: %s", target.u8string(), ec.message()); - } - - // Trailing backslash for directories - output.push_back(Strings::format(R"(%s/%s/)", destination_subdirectory, suffix)); - continue; - } + fs.create_directory(target, ec); + if (ec) + { + System::println(System::Color::error, "failed: %s: %s", target.u8string(), ec.message()); + } - if (fs::is_regular_file(status)) - { - if (fs.exists(target)) - { - System::println(System::Color::warning, - "File %s was already present and will be overwritten", - target.u8string(), - ec.message()); + // Trailing backslash for directories + output.push_back(Strings::format(R"(%s/%s/)", destination_subdirectory, suffix)); + break; } - fs.copy_file(file, target, fs::copy_options::overwrite_existing, ec); - if (ec) + case fs::file_type::regular: { - System::println(System::Color::error, "failed: %s: %s", target.u8string(), ec.message()); + if (fs.exists(target)) + { + System::println(System::Color::warning, + "File %s was already present and will be overwritten", + target.u8string(), + ec.message()); + } + fs.copy_file(file, target, fs::copy_options::overwrite_existing, ec); + if (ec) + { + System::println(System::Color::error, "failed: %s: %s", target.u8string(), ec.message()); + } + output.push_back(Strings::format(R"(%s/%s)", destination_subdirectory, suffix)); + break; } - 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; + default: + System::println(System::Color::error, "failed: %s: cannot handle file type", file.u8string()); + break; } - - System::println(System::Color::error, "failed: %s: cannot handle file type", file.u8string()); } std::sort(output.begin(), output.end()); |
