Mercurial > cgi-bin > hgweb.cgi > JpegWasher
comparison src/name/blackcap/exifwasher/exiv2/Initialize.kt @ 22:cd2ca4727b7f
Builds under Windows.
author | davidb |
---|---|
date | Thu, 16 Apr 2020 11:10:39 -0700 |
parents | 9ac6136c710c |
children |
comparison
equal
deleted
inserted
replaced
21:539c3641c539 | 22:cd2ca4727b7f |
---|---|
24 if (initialized) { | 24 if (initialized) { |
25 return | 25 return |
26 } | 26 } |
27 | 27 |
28 /* use the appropriate binary for the system we're on */ | 28 /* use the appropriate binary for the system we're on */ |
29 val subdir = when(OS.type) { | 29 val (subdir, pfx, ext) = when(OS.type) { |
30 OS.UNIX -> "linux" | 30 OS.UNIX -> Triple("linux", "lib", ".so") |
31 OS.MAC -> "mac" | 31 OS.MAC -> Triple("mac", "lib", ".dylib") |
32 OS.WINDOWS -> "windows" | 32 OS.WINDOWS -> Triple("windows", "", ".dll") |
33 OS.OTHER -> throw RuntimeException("unsupported OS!") | |
34 } | |
35 val ext = when(OS.type) { | |
36 OS.UNIX -> "so" | |
37 OS.MAC -> "dylib" | |
38 OS.WINDOWS -> "dll" | |
39 OS.OTHER -> throw RuntimeException("unsupported OS!") | 33 OS.OTHER -> throw RuntimeException("unsupported OS!") |
40 } | 34 } |
41 | 35 |
42 /* extract to scratch files, if needed, then load */ | 36 /* extract to scratch files, if needed, then load */ |
43 val klass = Initialize::class.java | 37 val klass = Initialize::class.java |
44 var myJar = JarFile(File(klass.getProtectionDomain().getCodeSource().getLocation().toURI())) | 38 var myJar = JarFile(File(klass.getProtectionDomain().getCodeSource().getLocation().toURI())) |
45 for (base in arrayOf("libexiv2", "libjni")) { | 39 for (base in arrayOf("exiv2", "jni")) { |
46 val eBase = "${base}.${ext}" | 40 val eBase = "${pfx}${base}${ext}" |
47 val sPath = "name/blackcap/exifwasher/binaries/${subdir}/${eBase}" | 41 val sPath = "name/blackcap/exifwasher/binaries/${subdir}/${eBase}" |
48 val source = myJar.getJarEntry(sPath) | 42 val source = myJar.getJarEntry(sPath) |
49 if (source == null) { | 43 if (source == null) { |
50 die("${sPath} not found in jar") | 44 die("${sPath} not found in jar") |
51 } | 45 } |