s243a

ContainerInserter.createTarBucket

Jun 7th, 2015
467
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1.  // Line 279 of https://github.com/freenet/fred/blob/next/src/freenet/client/async/ContainerInserter.java
  2. 279     /**
  3. 280     ** OutputStream os will be close()d if this method returns successfully.
  4. 281     */
  5. 282     private String createTarBucket(OutputStream os) throws IOException {
  6. 283         if(logMINOR) Logger.minor(this, "Create a TAR Bucket");
  7. 284          
  8. 285         TarArchiveOutputStream tarOS = new TarArchiveOutputStream(os);
  9. 286         try {
  10. 287             tarOS.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
  11. 288             TarArchiveEntry ze;
  12. 289
  13.  
  14. 290             for (ContainerElement ph : containerItems) {
  15. 291                 if (logMINOR)
  16. 292                     Logger.minor(this, "Putting into tar: " + ph + " data length " + ph.data.size() + " name " + ph.targetInArchive);
  17. 293                 ze = new TarArchiveEntry(ph.targetInArchive);
  18. 294                 ze.setModTime(0);
  19. 295                 long size = ph.data.size();
  20. 296                 ze.setSize(size);
  21. 297                 tarOS.putArchiveEntry(ze);
  22. 298                 BucketTools.copyTo(ph.data, tarOS, size);
  23. 299                 tarOS.closeArchiveEntry();
  24. 300             }
  25. 301         } finally {
  26. 302             tarOS.close();
  27. 303         }
  28. 304          
  29. 305         return ARCHIVE_TYPE.TAR.mimeTypes[0];
  30. 306     }
Advertisement
Add Comment
Please, Sign In to add comment