MCPcopy Create free account
hub / github.com/annmuor/jnode / createZipFile

Method createZipFile

jnode-core/src/jnode/ftn/FtnTools.java:1096–1126  ·  view source on GitHub ↗
(FtnPkt header, Link link,
			List<FtnMessage> messages)

Source from the content-addressed store, hash-verified

1094 }
1095
1096 private static File createZipFile(FtnPkt header, Link link,
1097 List<FtnMessage> messages) throws IOException {
1098 File np = createOutboundFile(link);
1099 FileOutputStream out = new FileOutputStream(np);
1100 ZipOutputStream zos = new ZipOutputStream(out);
1101 zos.setMethod(ZipOutputStream.DEFLATED);
1102 ZipEntry ze = new ZipEntry(String.format("%s.pkt", generate8d()));
1103 ze.setMethod(ZipEntry.DEFLATED);
1104 CRC32 crc32 = new CRC32();
1105 zos.putNextEntry(ze);
1106 int len = 0;
1107 byte[] data = header.pack();
1108 len += data.length;
1109 crc32.update(data);
1110 zos.write(data);
1111 for (FtnMessage m : messages) {
1112 data = m.pack();
1113 len += data.length;
1114 crc32.update(data);
1115 zos.write(data);
1116 }
1117 data = header.finalz();
1118 len += data.length;
1119 crc32.update(data);
1120 zos.write(data);
1121 ze.setSize(len);
1122 ze.setCrc(crc32.getValue());
1123 zos.close();
1124 out.close();
1125 return np;
1126 }
1127
1128 /**
1129 * Эхобандл

Callers 1

packMethod · 0.95

Calls 9

createOutboundFileMethod · 0.95
generate8dMethod · 0.95
formatMethod · 0.80
updateMethod · 0.80
finalzMethod · 0.80
setSizeMethod · 0.80
packMethod · 0.45
writeMethod · 0.45
getValueMethod · 0.45

Tested by

no test coverage detected