|
21 | 21 | import ru.olegcherednik.zip4jvm.exception.Zip4jvmException;
|
22 | 22 | import ru.olegcherednik.zip4jvm.io.out.data.EncoderDataOutput;
|
23 | 23 | import ru.olegcherednik.zip4jvm.io.out.entry.EntryMetadataOutputStream;
|
| 24 | +import ru.olegcherednik.zip4jvm.model.CompressionLevel; |
24 | 25 | import ru.olegcherednik.zip4jvm.model.CompressionMethod;
|
25 | 26 | import ru.olegcherednik.zip4jvm.model.entry.ZipEntry;
|
26 | 27 |
|
|
37 | 38 | @RequiredArgsConstructor(access = AccessLevel.PROTECTED)
|
38 | 39 | public abstract class EncryptedEntryOutputStream extends OutputStream {
|
39 | 40 |
|
40 |
| - protected final ZipEntry zipEntry; |
41 | 41 | protected final EncoderDataOutput encoderDataOutput;
|
42 | 42 | protected final EntryMetadataOutputStream emos;
|
43 | 43 |
|
44 |
| - public static EncryptedEntryOutputStream create(ZipEntry zipEntry, |
| 44 | + public static EncryptedEntryOutputStream create(ZipEntry entry, |
45 | 45 | EncoderDataOutput encoderDataOutput,
|
46 | 46 | EntryMetadataOutputStream emos) throws IOException {
|
47 |
| - CompressionMethod compressionMethod = zipEntry.getCompressionMethod(); |
| 47 | + |
| 48 | + CompressionMethod compressionMethod = entry.getCompressionMethod(); |
| 49 | + CompressionLevel compressionLevel = entry.getCompressionLevel(); |
48 | 50 |
|
49 | 51 | if (compressionMethod == CompressionMethod.STORE)
|
50 |
| - return new StoreEntryOutputStream(zipEntry, encoderDataOutput, emos); |
| 52 | + return new StoreEntryOutputStream(encoderDataOutput, emos); |
51 | 53 | if (compressionMethod == CompressionMethod.DEFLATE)
|
52 |
| - return new DeflateEntryOutputStream(zipEntry, encoderDataOutput, emos); |
| 54 | + return new DeflateEntryOutputStream(compressionLevel, encoderDataOutput, emos); |
53 | 55 | if (compressionMethod == CompressionMethod.BZIP2)
|
54 |
| - return new Bzip2EntryOutputStream(zipEntry, encoderDataOutput, emos); |
| 56 | + return new Bzip2EntryOutputStream(compressionLevel, encoderDataOutput, emos); |
55 | 57 | if (compressionMethod == CompressionMethod.LZMA)
|
56 |
| - return new LzmaEntryOutputStream(zipEntry, encoderDataOutput, emos); |
| 58 | + return new LzmaEntryOutputStream(compressionLevel, |
| 59 | + entry.isLzmaEosMarker(), |
| 60 | + entry.getUncompressedSize(), |
| 61 | + encoderDataOutput, |
| 62 | + emos); |
57 | 63 | if (compressionMethod == CompressionMethod.ZSTD)
|
58 |
| - return new ZstdEntryOutputStream(zipEntry, encoderDataOutput, emos); |
| 64 | + return new ZstdEntryOutputStream(compressionLevel, encoderDataOutput, emos); |
59 | 65 |
|
60 | 66 | throw new Zip4jvmException("Compression '%s' is not supported", compressionMethod);
|
61 | 67 | }
|
|
0 commit comments