diff options
| author | TitanSnow <[email protected]> | 2017-05-22 20:15:24 +0800 |
|---|---|---|
| committer | TitanSnow <[email protected]> | 2017-05-22 20:15:24 +0800 |
| commit | 7b2bd5ca66ae8ed9f890d32f86fee9501d84968a (patch) | |
| tree | a57d5a150568d79d468c878cd7eea73571af22bc | |
| parent | 5e36555036052217345596a1bab1e859ffaa8db0 (diff) | |
use privilege while uninstalling
| -rw-r--r-- | xmake/actions/uninstall/main.lua | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/xmake/actions/uninstall/main.lua b/xmake/actions/uninstall/main.lua index a7cfec3db..2b25a058d 100644 --- a/xmake/actions/uninstall/main.lua +++ b/xmake/actions/uninstall/main.lua @@ -26,6 +26,7 @@ import("core.base.option") import("core.project.task") import("core.platform.platform") +import("core.base.privilege") import("uninstall") -- main @@ -57,6 +58,28 @@ function main() -- failed or not permission? request administrator permission and uninstall it again function (errors) + -- try get privilege + if privilege.get() then + local ok = try + { + function () + -- uninstall target + uninstall.uninstall(targetname) + + -- trace + cprint("${bright}uninstall ok!${clear}${ok_hand}") + + -- ok + return true + end + } + + -- release privilege + privilege.store() + + if ok then return end + end + -- show tips cprint("${bright red}error: ${default red}failed to uninstall, may permission denied!") |
