Easy way to retrieve manifest for script bundle
This commit is contained in:
parent
21d643c544
commit
f6f3e411e3
|
@ -2,6 +2,7 @@ package net.filebot.cli;
|
||||||
|
|
||||||
import static java.nio.charset.StandardCharsets.*;
|
import static java.nio.charset.StandardCharsets.*;
|
||||||
import static java.util.Arrays.*;
|
import static java.util.Arrays.*;
|
||||||
|
import static java.util.stream.Collectors.*;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
@ -10,6 +11,7 @@ import java.security.cert.Certificate;
|
||||||
import java.security.cert.CertificateException;
|
import java.security.cert.CertificateException;
|
||||||
import java.security.cert.CertificateFactory;
|
import java.security.cert.CertificateFactory;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.jar.JarEntry;
|
import java.util.jar.JarEntry;
|
||||||
import java.util.jar.JarInputStream;
|
import java.util.jar.JarInputStream;
|
||||||
|
|
||||||
|
@ -52,4 +54,10 @@ public class ScriptBundle implements ScriptProvider {
|
||||||
throw new FileNotFoundException("Script not found: " + name);
|
throw new FileNotFoundException("Script not found: " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getManifest() throws Exception {
|
||||||
|
try (JarInputStream jar = new JarInputStream(new ByteArrayInputStream(bundle.get()), true)) {
|
||||||
|
return jar.getManifest().getMainAttributes().entrySet().stream().collect(toMap(it -> it.getKey().toString(), it -> it.getValue().toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue