Launcher/LaunchServer/src/main/java/ru/gravit/launchserver/binary/BuildContext.java

49 lines
1.4 KiB
Java
Raw Normal View History

2018-09-19 16:14:50 +03:00
package ru.gravit.launchserver.binary;
import ru.gravit.utils.helper.IOHelper;
import java.io.IOException;
import java.io.InputStream;
2018-09-19 16:29:31 +03:00
import java.util.Set;
2018-09-19 16:14:50 +03:00
import java.util.jar.JarInputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
public class BuildContext {
public final ZipOutputStream output;
public final JAConfigurator config;
public BuildContext(ZipOutputStream output, JAConfigurator config) {
this.output = output;
this.config = config;
}
2018-09-22 17:33:00 +03:00
public void pushFile(String filename, InputStream inputStream) throws IOException {
2018-09-19 16:14:50 +03:00
ZipEntry zip = IOHelper.newZipEntry(filename);
output.putNextEntry(zip);
2018-09-22 17:33:00 +03:00
IOHelper.transfer(inputStream, output);
2018-09-19 16:14:50 +03:00
}
2018-09-22 17:33:00 +03:00
2018-09-19 16:14:50 +03:00
public void pushJarFile(JarInputStream input) throws IOException {
ZipEntry e = input.getNextEntry();
while (e != null) {
output.putNextEntry(e);
2018-09-22 17:33:00 +03:00
IOHelper.transfer(input, output);
2018-09-19 16:14:50 +03:00
e = input.getNextEntry();
}
}
2018-09-22 17:33:00 +03:00
2018-09-19 16:29:31 +03:00
public void pushJarFile(JarInputStream input, Set<String> blacklist) throws IOException {
ZipEntry e = input.getNextEntry();
while (e != null) {
2018-09-22 17:33:00 +03:00
if (blacklist.contains(e.getName())) {
2018-09-19 16:29:31 +03:00
e = input.getNextEntry();
continue;
}
output.putNextEntry(e);
2018-09-22 17:33:00 +03:00
IOHelper.transfer(input, output);
2018-09-19 16:29:31 +03:00
e = input.getNextEntry();
}
}
2018-09-19 16:14:50 +03:00
}