fix: remove unused util methods/exceptions

This commit is contained in:
Connor Tumbleson 2021-03-28 17:10:52 -04:00
parent 3d3dd07cf2
commit 64eda064eb
No known key found for this signature in database
GPG Key ID: C3CC0A201EC7DA75
2 changed files with 8 additions and 35 deletions

View File

@ -39,37 +39,10 @@ abstract public class Jar {
return file; 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 { public static File extractToTmp(String resourcePath, Class clazz) throws BrutException {
return extractToTmp(resourcePath, "brut_util_Jar_", clazz); 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 { public static File extractToTmp(String resourcePath, String tmpPrefix, Class clazz) throws BrutException {
try { try {
InputStream in = clazz.getResourceAsStream(resourcePath); InputStream in = clazz.getResourceAsStream(resourcePath);

View File

@ -49,7 +49,7 @@ public class OS {
dir.delete(); dir.delete();
} }
public static void rmfile(String file) throws BrutException { public static void rmfile(String file) {
File del = new File(file); File del = new File(file);
del.delete(); 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 { public static void exec(String[] cmd) throws BrutException {
Process ps = null; Process ps;
int exitValue = -99; int exitValue;
try { try {
ProcessBuilder builder = new ProcessBuilder(cmd); ProcessBuilder builder = new ProcessBuilder(cmd);
ps = builder.start(); ps = builder.start();
new StreamForwarder(ps.getErrorStream(), "ERROR").start(); new StreamForwarder(ps.getErrorStream(), "ERROR").start();
new StreamForwarder(ps.getInputStream(), "OUTPUT").start(); new StreamForwarder(ps.getInputStream(), "OUTPUT").start();
exitValue = ps.waitFor(); exitValue = ps.waitFor();
if (exitValue != 0) if (exitValue != 0) {
throw new BrutException("could not exec (exit code = " + exitValue + "): " + Arrays.toString(cmd)); throw new BrutException("could not exec (exit code = " + exitValue + "): " + Arrays.toString(cmd));
}
} catch (IOException ex) { } catch (IOException ex) {
throw new BrutException("could not exec: " + Arrays.toString(cmd), ex); throw new BrutException("could not exec: " + Arrays.toString(cmd), ex);
} catch (InterruptedException ex) { } catch (InterruptedException ex) {