summaryrefslogtreecommitdiff
path: root/pdf-over-install-helper/src/main/java
diff options
context:
space:
mode:
authorJakob Heher <jakob.heher@iaik.tugraz.at>2022-03-22 13:52:29 +0100
committerJakob Heher <jakob.heher@iaik.tugraz.at>2022-03-22 13:52:29 +0100
commit0953f7cde8a2c09850f398790adc983ebf7f1b8b (patch)
tree60215d314905a71c545ff637061bb945f2eeee5f /pdf-over-install-helper/src/main/java
parent5cc1081113429add3b70887b47b4be4b8da8cf69 (diff)
downloadpdf-over-0953f7cde8a2c09850f398790adc983ebf7f1b8b.tar.gz
pdf-over-0953f7cde8a2c09850f398790adc983ebf7f1b8b.tar.bz2
pdf-over-0953f7cde8a2c09850f398790adc983ebf7f1b8b.zip
sanitize swt handling
Diffstat (limited to 'pdf-over-install-helper/src/main/java')
-rw-r--r--pdf-over-install-helper/src/main/java/at/asit/helper/Main.java135
1 files changed, 0 insertions, 135 deletions
diff --git a/pdf-over-install-helper/src/main/java/at/asit/helper/Main.java b/pdf-over-install-helper/src/main/java/at/asit/helper/Main.java
deleted file mode 100644
index edf5ec2f..00000000
--- a/pdf-over-install-helper/src/main/java/at/asit/helper/Main.java
+++ /dev/null
@@ -1,135 +0,0 @@
-package at.asit.helper;
-
-import java.io.File;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-
-import org.apache.commons.io.FileUtils;
-
-
-
-
-/***
- *
- * @author aabraham
- *
- * @version 1.0.0
- *
- * The created jar is used as helper library when installing pdf-over.
- * Basically, the helper determines the java version used including architecture and
- * appends afterwards the right swt library since this swt is platform dependend.
- *
- */
-public class Main {
-
- private final static String SWT_VERSION = "4.20";
-
- public static void main(String[] args) {
-
- System.out.println("start post install task");
-
- copyLib();
-
- }
-
-
- public static int getArchBits() {
- String arch = System.getProperty("sun.arch.data.model");
- return arch.contains("64") ? 64 : 32;
- }
-
- public static String getSwtJarName() throws SWTLoadFailedException {
- String os = System.getProperty("os.name").toLowerCase();
- if (os.contains("win"))
- os = "windows";
- else if (os.contains("mac"))
- os = "mac";
- else if (os.contains("linux") || os.contains("nix"))
- os = "linux";
- else {
- throw new SWTLoadFailedException("Unknown OS: " + os);
- }
- return "swt-" + os + "-" + getArchBits() + ".jar";
- }
-
- public static String getSwtJarPath() {
- String path = "";
- try {
- path = URLDecoder.decode(Main.class.getProtectionDomain().getCodeSource().getLocation().getPath(), "UTF-8");
- int idx = path.lastIndexOf('/');
- idx = path.lastIndexOf('/', idx - 1);
- path = path.substring(0, idx + 1);
- } catch (UnsupportedEncodingException e) {
- // Ignore
- System.err.println("Unsuported Encoding Exception " + e.getMessage());
- }
- return path + "lib-swt/";
- }
-
- private static class SWTLoadFailedException extends Exception {
- private static final long serialVersionUID = 1L;
-
- SWTLoadFailedException(String msg) {
- super(msg);
- }
- }
-
-
- private static String getSwtTargetLibName() throws SWTLoadFailedException {
-
- String os = System.getProperty("os.name").toLowerCase();
- System.out.println("OS " + os + " detected!");
- String swtTargetLibName;
-
- if (os.contains("win")) {
- swtTargetLibName = "org.eclipse.swt.win32.win32.x86-" + SWT_VERSION + ".jar";
- }
- else if (os.contains("mac")) {
- swtTargetLibName = "org.eclipse.swt.cocoa.macosx-" + SWT_VERSION + ".jar";
- }
- else if (os.contains("linux") || os.contains("nix")) {
- swtTargetLibName = "org.eclipse.swt.gtk.linux.x86-" + SWT_VERSION + ".jar";
- }
- else {
- throw new SWTLoadFailedException("Unknown OS: " + os);
- }
- return swtTargetLibName;
-
-
- }
-
-
- private static void copyLib() {
- try {
- String swtLibPath = Main.getSwtJarPath() + Main.getSwtJarName();
- File swtLib = new File(swtLibPath);
- if (!swtLib.isFile()) {
-
- System.err.println("not found ");
- throw new SWTLoadFailedException("Library " + swtLibPath + " not found");
- }
-
- String newPath = swtLibPath.replace("lib-swt", "lib");
- newPath = newPath.replace(Main.getSwtJarName(), getSwtTargetLibName());
- File newFile = new File(newPath);
- System.out.println("Source Lib " + swtLibPath.toString());
- System.out.println("Target Lib " + newFile.toString());
- FileUtils.copyFile(swtLib, newFile);
-
- if (!newFile.isFile()) {
- System.err.println("not found ");
- throw new SWTLoadFailedException("Library " + swtLibPath + " not found");
- }
-
- System.out.println("success ");
- return;
-
-
- } catch(Exception e){
- e.printStackTrace();
- }
-
- }
-
-
-}