mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
Фитча для модулей - список файлов в jar лаунчера
Упрощает процедуру внедрения своих файлов в JAR
This commit is contained in:
parent
e915d408a9
commit
0862e3c541
2 changed files with 12 additions and 0 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
@ -13,24 +14,33 @@ public class BuildContext {
|
|||
public final ZipOutputStream output;
|
||||
public final JAConfigurator config;
|
||||
public final JARLauncherBinary data;
|
||||
public final HashSet<String> fileList;
|
||||
|
||||
|
||||
public BuildContext(ZipOutputStream output, JAConfigurator config, JARLauncherBinary data) {
|
||||
this.output = output;
|
||||
this.config = config;
|
||||
this.data = data;
|
||||
fileList = new HashSet<>(1024);
|
||||
}
|
||||
|
||||
public void pushFile(String filename, InputStream inputStream) throws IOException {
|
||||
ZipEntry zip = IOHelper.newZipEntry(filename);
|
||||
output.putNextEntry(zip);
|
||||
IOHelper.transfer(inputStream, output);
|
||||
fileList.add(filename);
|
||||
}
|
||||
|
||||
public void pushJarFile(ZipInputStream input) throws IOException {
|
||||
ZipEntry e = input.getNextEntry();
|
||||
while (e != null) {
|
||||
if (fileList.contains(e.getName())) {
|
||||
e = input.getNextEntry();
|
||||
continue;
|
||||
}
|
||||
output.putNextEntry(e);
|
||||
IOHelper.transfer(input, output);
|
||||
fileList.add(e.getName());
|
||||
e = input.getNextEntry();
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +54,7 @@ public void pushJarFile(ZipInputStream input, Set<String> blacklist) throws IOEx
|
|||
}
|
||||
output.putNextEntry(e);
|
||||
IOHelper.transfer(input, output);
|
||||
fileList.add(e.getName());
|
||||
e = input.getNextEntry();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -242,6 +242,7 @@ private void stdBuild() throws IOException {
|
|||
}
|
||||
} else
|
||||
IOHelper.transfer(input, output);
|
||||
context.fileList.add(filename);
|
||||
e = input.getNextEntry();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue