From 64eda064eb8eb439557cc77167524c13101a31cc Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Sun, 28 Mar 2021 17:10:52 -0400 Subject: [PATCH] fix: remove unused util methods/exceptions --- brut.j.util/src/main/java/brut/util/Jar.java | 27 -------------------- brut.j.util/src/main/java/brut/util/OS.java | 16 ++++++------ 2 files changed, 8 insertions(+), 35 deletions(-) diff --git a/brut.j.util/src/main/java/brut/util/Jar.java b/brut.j.util/src/main/java/brut/util/Jar.java index f3185816..b9d2745e 100644 --- a/brut.j.util/src/main/java/brut/util/Jar.java +++ b/brut.j.util/src/main/java/brut/util/Jar.java @@ -39,37 +39,10 @@ abstract public class Jar { return file; } - public static File getResourceAsFile(String name) throws BrutException { - return getResourceAsFile(name, Class.class); - } - - public static void load(String libPath) { - if (mLoaded.contains(libPath)) { - return; - } - - File libFile; - try { - libFile = getResourceAsFile(libPath); - } catch (BrutException ex) { - throw new UnsatisfiedLinkError(ex.getMessage()); - } - - System.load(libFile.getAbsolutePath()); - } - - public static File extractToTmp(String resourcePath) throws BrutException { - return extractToTmp(resourcePath, Class.class); - } - public static File extractToTmp(String resourcePath, Class clazz) throws BrutException { return extractToTmp(resourcePath, "brut_util_Jar_", clazz); } - public static File extractToTmp(String resourcePath, String tmpPrefix) throws BrutException { - return extractToTmp(resourcePath, tmpPrefix, Class.class); - } - public static File extractToTmp(String resourcePath, String tmpPrefix, Class clazz) throws BrutException { try { InputStream in = clazz.getResourceAsStream(resourcePath); diff --git a/brut.j.util/src/main/java/brut/util/OS.java b/brut.j.util/src/main/java/brut/util/OS.java index c70c797c..e9b8636f 100644 --- a/brut.j.util/src/main/java/brut/util/OS.java +++ b/brut.j.util/src/main/java/brut/util/OS.java @@ -49,7 +49,7 @@ public class OS { dir.delete(); } - public static void rmfile(String file) throws BrutException { + public static void rmfile(String file) { File del = new File(file); del.delete(); } @@ -83,21 +83,21 @@ public class OS { } } - public static void cpdir(String src, String dest) throws BrutException { - cpdir(new File(src), new File(dest)); - } - public static void exec(String[] cmd) throws BrutException { - Process ps = null; - int exitValue = -99; + Process ps; + int exitValue; + try { ProcessBuilder builder = new ProcessBuilder(cmd); ps = builder.start(); + new StreamForwarder(ps.getErrorStream(), "ERROR").start(); new StreamForwarder(ps.getInputStream(), "OUTPUT").start(); + exitValue = ps.waitFor(); - if (exitValue != 0) + if (exitValue != 0) { throw new BrutException("could not exec (exit code = " + exitValue + "): " + Arrays.toString(cmd)); + } } catch (IOException ex) { throw new BrutException("could not exec: " + Arrays.toString(cmd), ex); } catch (InterruptedException ex) {