diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2017-02-28 18:23:48 -0800 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2017-02-28 18:23:48 -0800 |
| commit | 56d322dcb12dfaf95cd3cb9976110aa7d0cc9a15 (patch) | |
| tree | 94976a27f01884f5f2213f801a6ed3b88675fa72 /toolsrc/src/commands_integrate.cpp | |
| parent | ab0d61b77947591e62006a92633c1411bdefa6e5 (diff) | |
| download | vcpkg-56d322dcb12dfaf95cd3cb9976110aa7d0cc9a15.tar.gz vcpkg-56d322dcb12dfaf95cd3cb9976110aa7d0cc9a15.zip | |
Improve implementation of `vcpkg integrate remove`
Diffstat (limited to 'toolsrc/src/commands_integrate.cpp')
| -rw-r--r-- | toolsrc/src/commands_integrate.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/toolsrc/src/commands_integrate.cpp b/toolsrc/src/commands_integrate.cpp index 595cf3914..3d5a9daeb 100644 --- a/toolsrc/src/commands_integrate.cpp +++ b/toolsrc/src/commands_integrate.cpp @@ -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); } |
