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

Method unpackBundle

jnode-core/src/jnode/ftn/FtnTools.java:645–678  ·  view source on GitHub ↗
(Message message)

Source from the content-addressed store, hash-verified

643 }
644
645 protected static void unpackBundle(Message message) throws IOException {
646 logger.l4("Unpacking " + message.getMessageName());
647 ZipInputStream zis = new ZipInputStream(message.getInputStream());
648 ZipEntry ze;
649 while ((ze = zis.getNextEntry()) != null) {
650 String name = ze.getName().toLowerCase();
651 logger.l5("found " + name);
652 int idx = name.lastIndexOf('/');
653 if (idx >= 0) {
654 name = name.substring(idx + 1);
655 }
656 idx = name.lastIndexOf('\\');
657 if (idx >= 0) {
658 name = name.substring(idx + 1);
659 }
660 if (name.matches("^[a-f0-9]{8}\\.pkt$")) {
661 File out = createInboundFile(message.isSecure());
662 FileOutputStream fos = new FileOutputStream(out);
663 int len = 0;
664 do {
665 byte[] buf = new byte[1024];
666 len = zis.read(buf);
667 if (len > 0) {
668 fos.write(buf, 0, len);
669 }
670 } while (len > 0);
671 fos.close();
672 logger.l4(name + " was written as " + out.getName());
673 } else {
674 logger.l3(name + " was deleted as unknown");
675 }
676 }
677 zis.close();
678 }
679
680 public static File guessFilename(String filename, boolean read) {
681 filename = filename.replaceAll("^[\\./\\\\]+", "_");

Callers 1

unpackMethod · 0.95

Calls 10

createInboundFileMethod · 0.95
l4Method · 0.80
getMessageNameMethod · 0.80
getInputStreamMethod · 0.80
l5Method · 0.80
isSecureMethod · 0.80
readMethod · 0.80
l3Method · 0.80
getNameMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected