From 4312149537b892f7c05233cfd0ca7da751f2501d Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" <Ilya.Kazakevich@jetbrains.com> Date: Wed, 9 Aug 2017 23:54:42 +0300 Subject: [PATCH] IDEA-85995: Remove unneeded code and constant --- .../com/intellij/execution/util/ExecUtil.java | 2 +- .../updateSettings/impl/UpdateInstaller.kt | 2 +- .../openapi/application/PathManager.java | 4 -- .../intellij/openapi/util/io/FileUtil.java | 39 +------------------ 4 files changed, 3 insertions(+), 44 deletions(-) diff --git a/platform/platform-api/src/com/intellij/execution/util/ExecUtil.java b/platform/platform-api/src/com/intellij/execution/util/ExecUtil.java index 47195b687e2b..8c76621ddfd2 100644 --- a/platform/platform-api/src/com/intellij/execution/util/ExecUtil.java +++ b/platform/platform-api/src/com/intellij/execution/util/ExecUtil.java @@ -150,7 +150,7 @@ public class ExecUtil { final GeneralCommandLine sudoCommandLine; if (SystemInfo.isWinVistaOrNewer) { // launcher.exe process with elevated permissions on UAC. - final File launcherExe = PathManager.findBinFileWithException(PathManager.WIN_LAUNCHER); + final File launcherExe = PathManager.findBinFileWithException("launcher.exe"); sudoCommandLine = new GeneralCommandLine(launcherExe.getPath()); sudoCommandLine.setWorkDirectory(commandLine.getWorkDirectory()); sudoCommandLine.addParameter(commandLine.getExePath()); diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateInstaller.kt b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateInstaller.kt index 015bef68c408..b863df682be2 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateInstaller.kt +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateInstaller.kt @@ -136,7 +136,7 @@ object UpdateInstaller { if (SystemInfo.isWindows) { // launcher depends on elevator - val launcher = PathManager.findBinFile(PathManager.WIN_LAUNCHER) + val launcher = PathManager.findBinFile("launcher.exe") val elevator = PathManager.findBinFile("elevator.exe") if (launcher !=null && elevator != null && launcher.canExecute()) { args += Restarter.createTempExecutable(launcher, elevator).path diff --git a/platform/util/src/com/intellij/openapi/application/PathManager.java b/platform/util/src/com/intellij/openapi/application/PathManager.java index a6ff7b28b433..cc7a6f063ee0 100644 --- a/platform/util/src/com/intellij/openapi/application/PathManager.java +++ b/platform/util/src/com/intellij/openapi/application/PathManager.java @@ -55,10 +55,6 @@ public class PathManager { public static final String PROPERTY_LOG_PATH = "idea.log.path"; public static final String PROPERTY_PATHS_SELECTOR = "idea.paths.selector"; public static final String DEFAULT_OPTIONS_FILE_NAME = "other"; - /** - * Tool to launch any command under UAC - */ - public static final String WIN_LAUNCHER = "launcher.exe"; private static final String PROPERTY_HOME = "idea.home"; // reduced variant of PROPERTY_HOME_PATH, now deprecated diff --git a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java index b0f6a77e61b5..45845a8e0092 100644 --- a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java +++ b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java @@ -480,17 +480,7 @@ public class FileUtil extends FileUtilRt { @SuppressWarnings("Duplicates") private static void performCopy(@NotNull File fromFile, @NotNull File toFile, final boolean syncTimestamp) throws IOException { if (filesEqual(fromFile, toFile)) return; - final FileOutputStream fos; - try { - fos = openOutputStream(toFile); - } - catch (IOException e) { - if (SystemInfo.isWindows && e.getMessage() != null && e.getMessage().contains("denied") && - nativeWindowsCopy(fromFile, toFile)) { - return; - } - throw e; - } + final FileOutputStream fos = openOutputStream(toFile); try { final FileInputStream fis = new FileInputStream(fromFile); @@ -520,33 +510,6 @@ public class FileUtil extends FileUtilRt { } } - private static boolean nativeWindowsCopy(@NotNull final File src, @NotNull final File dst) { - final File launcher = PathManager.findBinFile(PathManager.WIN_LAUNCHER); - if (launcher == null || !launcher.exists()) { - return false; - } - - try { - final ProcessBuilder builder = - new ProcessBuilder(launcher.getAbsolutePath(), "cmd.exe", "/C", "copy", src.getAbsolutePath(), dst.getAbsolutePath()); - final Process process = builder.start(); - - final String error = StreamUtil.readText(process.getErrorStream(), Charset.defaultCharset()); - final String out = StreamUtil.readText(process.getInputStream(), Charset.defaultCharset()); - LOG.info("out" + out); - LOG.info("error" + error); - return process.waitFor() == 0; - } - catch (final IOException ex) { - LOG.warn(ex); - return false; - } - catch (final InterruptedException ex) { - LOG.warn(ex); - return false; - } - } - private static FileOutputStream openOutputStream(@NotNull final File file) throws IOException { try { return new FileOutputStream(file); -- GitLab