@Test public void simple() throws Exception { File folder = temporary.newFolder(); File file = WinUtilsInstaller.put(folder); assertThat(file.isFile(), is(true)); assertThat(file.getName(), endsWith(".exe")); assertThat(file.canExecute(), is(true)); assertThat(file.getCanonicalFile().getParentFile(), is(folder.getCanonicalFile())); }
public static File put(File directory) throws IOException { TemporaryFileInstaller installer = prepare(); assert installer != null; File file = new File(directory, TARGET_PREFIX + TARGET_SUFFIX); try { LOG.info(MessageFormat.format( "installing winutils.exe into default location: {0}", file)); installer.install(file, true); return file; } catch (IOException e) { LOG.debug(MessageFormat.format( "failed to install winutils into the default location: {0}", file), e); } File temp = null; boolean success = false; try { temp = File.createTempFile(TARGET_PREFIX + '-', TARGET_SUFFIX, directory); LOG.info(MessageFormat.format( "installing winutils.exe into temporary location: {0}", temp)); installer.install(temp, false); temp.deleteOnExit(); success = true; return temp; } catch (IOException e) { LOG.debug(MessageFormat.format( "failed to install winutils into a temporary location: {0}", temp), e); } finally { if (success == false) { if (temp != null && temp.delete() == false) { LOG.warn(MessageFormat.format( "failed to delete a temporary file: {0}", temp)); } } } throw new IOException(MessageFormat.format( "error occurred while installing winutils: {0}", file)); }
WinUtilsInstaller { public static File put(File directory) throws IOException { TemporaryFileInstaller installer = prepare(); assert installer != null; File file = new File(directory, TARGET_PREFIX + TARGET_SUFFIX); try { LOG.info(MessageFormat.format( "installing winutils.exe into default location: {0}", file)); installer.install(file, true); return file; } catch (IOException e) { LOG.debug(MessageFormat.format( "failed to install winutils into the default location: {0}", file), e); } File temp = null; boolean success = false; try { temp = File.createTempFile(TARGET_PREFIX + '-', TARGET_SUFFIX, directory); LOG.info(MessageFormat.format( "installing winutils.exe into temporary location: {0}", temp)); installer.install(temp, false); temp.deleteOnExit(); success = true; return temp; } catch (IOException e) { LOG.debug(MessageFormat.format( "failed to install winutils into a temporary location: {0}", temp), e); } finally { if (success == false) { if (temp != null && temp.delete() == false) { LOG.warn(MessageFormat.format( "failed to delete a temporary file: {0}", temp)); } } } throw new IOException(MessageFormat.format( "error occurred while installing winutils: {0}", file)); } }
WinUtilsInstaller { public static File put(File directory) throws IOException { TemporaryFileInstaller installer = prepare(); assert installer != null; File file = new File(directory, TARGET_PREFIX + TARGET_SUFFIX); try { LOG.info(MessageFormat.format( "installing winutils.exe into default location: {0}", file)); installer.install(file, true); return file; } catch (IOException e) { LOG.debug(MessageFormat.format( "failed to install winutils into the default location: {0}", file), e); } File temp = null; boolean success = false; try { temp = File.createTempFile(TARGET_PREFIX + '-', TARGET_SUFFIX, directory); LOG.info(MessageFormat.format( "installing winutils.exe into temporary location: {0}", temp)); installer.install(temp, false); temp.deleteOnExit(); success = true; return temp; } catch (IOException e) { LOG.debug(MessageFormat.format( "failed to install winutils into a temporary location: {0}", temp), e); } finally { if (success == false) { if (temp != null && temp.delete() == false) { LOG.warn(MessageFormat.format( "failed to delete a temporary file: {0}", temp)); } } } throw new IOException(MessageFormat.format( "error occurred while installing winutils: {0}", file)); } private  WinUtilsInstaller(); }
WinUtilsInstaller { public static File put(File directory) throws IOException { TemporaryFileInstaller installer = prepare(); assert installer != null; File file = new File(directory, TARGET_PREFIX + TARGET_SUFFIX); try { LOG.info(MessageFormat.format( "installing winutils.exe into default location: {0}", file)); installer.install(file, true); return file; } catch (IOException e) { LOG.debug(MessageFormat.format( "failed to install winutils into the default location: {0}", file), e); } File temp = null; boolean success = false; try { temp = File.createTempFile(TARGET_PREFIX + '-', TARGET_SUFFIX, directory); LOG.info(MessageFormat.format( "installing winutils.exe into temporary location: {0}", temp)); installer.install(temp, false); temp.deleteOnExit(); success = true; return temp; } catch (IOException e) { LOG.debug(MessageFormat.format( "failed to install winutils into a temporary location: {0}", temp), e); } finally { if (success == false) { if (temp != null && temp.delete() == false) { LOG.warn(MessageFormat.format( "failed to delete a temporary file: {0}", temp)); } } } throw new IOException(MessageFormat.format( "error occurred while installing winutils: {0}", file)); } private  WinUtilsInstaller(); static boolean isTarget(); static boolean isAlreadyInstalled(); static File put(File directory); static void register(File executable); }
WinUtilsInstaller { public static File put(File directory) throws IOException { TemporaryFileInstaller installer = prepare(); assert installer != null; File file = new File(directory, TARGET_PREFIX + TARGET_SUFFIX); try { LOG.info(MessageFormat.format( "installing winutils.exe into default location: {0}", file)); installer.install(file, true); return file; } catch (IOException e) { LOG.debug(MessageFormat.format( "failed to install winutils into the default location: {0}", file), e); } File temp = null; boolean success = false; try { temp = File.createTempFile(TARGET_PREFIX + '-', TARGET_SUFFIX, directory); LOG.info(MessageFormat.format( "installing winutils.exe into temporary location: {0}", temp)); installer.install(temp, false); temp.deleteOnExit(); success = true; return temp; } catch (IOException e) { LOG.debug(MessageFormat.format( "failed to install winutils into a temporary location: {0}", temp), e); } finally { if (success == false) { if (temp != null && temp.delete() == false) { LOG.warn(MessageFormat.format( "failed to delete a temporary file: {0}", temp)); } } } throw new IOException(MessageFormat.format( "error occurred while installing winutils: {0}", file)); } private  WinUtilsInstaller(); static boolean isTarget(); static boolean isAlreadyInstalled(); static File put(File directory); static void register(File executable);  }