Improve implementation of vcpkg integrate remove

This commit is contained in:
Alexander Karatarakis 2017-02-28 18:23:48 -08:00
parent ab0d61b779
commit 56d322dcb1

View File

@ -228,20 +228,25 @@ namespace vcpkg::Commands::Integrate
static void integrate_remove()
{
const fs::path path = get_appdata_targets_path();
if (!fs::exists(path))
std::error_code ec;
bool was_deleted = fs::remove(path, ec);
if (ec)
{
System::println(System::color::success, "User-wide integration is not installed");
exit(EXIT_SUCCESS);
System::println(System::color::error, "Error: Unable to remove user-wide integration: %d", ec.message());
exit(EXIT_FAILURE);
}
const std::wstring cmd_line = Strings::wformat(LR"(DEL "%s")", path.native());
const int exit_code = System::cmd_execute(cmd_line);
if (exit_code)
if (was_deleted)
{
System::println(System::color::error, "Error: Unable to remove user-wide integration: %d", exit_code);
exit(exit_code);
System::println(System::color::success, "User-wide integration was removed");
}
System::println(System::color::success, "User-wide integration was removed");
else
{
System::println(System::color::success, "User-wide integration is not installed");
}
exit(EXIT_SUCCESS);
}