2020-05-02 16:14:47 +00:00
|
|
|
import '@ccms/nashorn'
|
2019-09-07 04:23:15 +00:00
|
|
|
|
|
|
|
let Files = Java.type("java.nio.file.Files");
|
|
|
|
let Paths = Java.type("java.nio.file.Paths");
|
|
|
|
let StandardCopyOption = Java.type("java.nio.file.StandardCopyOption");
|
|
|
|
|
|
|
|
let TarInputStream = Java.type("org.kamranzafar.jtar.TarInputStream");
|
|
|
|
let GZIPInputStream = Java.type("java.util.zip.GZIPInputStream");
|
|
|
|
let BufferedInputStream = Java.type("java.io.BufferedInputStream");
|
|
|
|
|
|
|
|
function decompression(input: any, target: string) {
|
|
|
|
let tis = new TarInputStream(new BufferedInputStream(new GZIPInputStream(input)));
|
|
|
|
let entry: any;
|
|
|
|
while ((entry = tis.getNextEntry()) != null) {
|
|
|
|
let targetPath = Paths.get(target + "/" + entry.getName().substring("package/".length));
|
|
|
|
targetPath.toFile().getParentFile().mkdirs();
|
|
|
|
Files.copy(tis, targetPath, StandardCopyOption.REPLACE_EXISTING);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export = {
|
|
|
|
decompression
|
|
|
|
}
|