Init: Create & Init ms Project...
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
23
packages/common/src/tgz.ts
Normal file
23
packages/common/src/tgz.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import '@ms/nashorn'
|
||||
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user