/** * Entry point for phase 1. This class tries to remove all files given in the Vector. * * @param temporaryFileNames * @throws IOException */ public static void invoke(List<String> temporaryFileNames) throws IOException { LibraryRemover self = new LibraryRemover(1); self.invoke1(temporaryFileNames); }
private void log(String msg) { if (checkLog() != null) { log.println(isoPoint.format(date) + " Phase " + phase + ": " + msg); } }
public static void main(String[] args) { // Phase 2 removes given path list, sandbox and spec file. // Phase 3 as used in SelfModifier will be not needed here because // this class do not use a GUI which can call exit like the // one in SelfModifier. try { // all it's attributes are retrieved from system properties LibraryRemover librianRemover = new LibraryRemover(2); librianRemover.invoke2(); } catch (IOException ioe) { System.err.println("Error invoking a secondary phase"); System.err.println("Note that this program is only intended as a secondary process"); ioe.printStackTrace(); } }
ArrayList<File> files = getFilesList(); log("deleteing temporary dlls/shls"); for (File file : files) if (file.exists()) log(" deleting of " + file.getCanonicalPath() + " failed!!!"); log(" " + file.getCanonicalPath()); log("deleteing sandbox"); deleteTree(sandbox); specFile.delete(); log(e);
/** * Recursively delete a file structure. Copied from com.izforge.izpack.uninstaller.SelfModifier. * Little addaption to this class. * * @return command for spawning */ public static boolean deleteTree(File file) { if (file.isDirectory()) { File[] files = file.listFiles(); if (files != null) { for (File file1 : files) { deleteTree(file1); } } } return file.delete(); }
LibraryRemover.invoke(temporaryFileNames);
/** * Copied from com.izforge.izpack.uninstaller.SelfModifier. Little addaption for this class. * * @param nextPhase phase of the spawn * @return created process object * @throws IOException */ private Process spawn(int nextPhase) throws IOException { String base = logFile.getAbsolutePath(); base = base.substring(0, base.length() - 4); // invoke from tmpdir, passing target method arguments as args, and // SelfModifier parameters as sustem properties String[] javaCmd = new String[]{ProcessHelper.getJavaCommand(), "-classpath", sandbox.getAbsolutePath(), "-D" + BASE_KEY + "=" + base, "-D" + PHASE_KEY + "=" + nextPhase, getClass().getName()}; StringBuilder sb = new StringBuilder("Spawning phase "); sb.append(nextPhase).append(": "); for (String aJavaCmd : javaCmd) { sb.append("\n\t").append(aJavaCmd); } log(sb.toString()); // Just invoke it and let it go, the exception will be caught above return ProcessHelper.exec(javaCmd); }
private void log(Throwable t) { if (checkLog() != null) { log.println(isoPoint.format(date) + " Phase " + phase + ": " + t.getMessage()); t.printStackTrace(log); } }