@Test public void testCreateArchivePermissionsPreserved() throws Exception { setPermissionsTo700(); archiver.createArchive(); assertEquals(0700, getTarEntries().get("dir2/testPermissions").getMode()); }
public void createArchive() throws IOException { validate(); log.info("Building tar: " + destFile); TarArchiveOutputStream tarStream = null; try { destFile.getAbsoluteFile().getParentFile().mkdirs(); GzipCompressorOutputStream gzipStream = new GzipCompressorOutputStream( new BufferedOutputStream(new FileOutputStream(destFile))); tarStream = new TarArchiveOutputStream(gzipStream, "UTF-8"); tarStream.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU); for (File sourceDir : sourceDirs) { for (File child : sourceDir.listFiles()) { addToTarRecursively(sourceDir, child, tarStream); } } } finally { if (tarStream != null) { tarStream.close(); } } }
TarGzArchiver { public void createArchive() throws IOException { validate(); log.info("Building tar: " + destFile); TarArchiveOutputStream tarStream = null; try { destFile.getAbsoluteFile().getParentFile().mkdirs(); GzipCompressorOutputStream gzipStream = new GzipCompressorOutputStream( new BufferedOutputStream(new FileOutputStream(destFile))); tarStream = new TarArchiveOutputStream(gzipStream, "UTF-8"); tarStream.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU); for (File sourceDir : sourceDirs) { for (File child : sourceDir.listFiles()) { addToTarRecursively(sourceDir, child, tarStream); } } } finally { if (tarStream != null) { tarStream.close(); } } } }
TarGzArchiver { public void createArchive() throws IOException { validate(); log.info("Building tar: " + destFile); TarArchiveOutputStream tarStream = null; try { destFile.getAbsoluteFile().getParentFile().mkdirs(); GzipCompressorOutputStream gzipStream = new GzipCompressorOutputStream( new BufferedOutputStream(new FileOutputStream(destFile))); tarStream = new TarArchiveOutputStream(gzipStream, "UTF-8"); tarStream.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU); for (File sourceDir : sourceDirs) { for (File child : sourceDir.listFiles()) { addToTarRecursively(sourceDir, child, tarStream); } } } finally { if (tarStream != null) { tarStream.close(); } } } TarGzArchiver(); }
TarGzArchiver { public void createArchive() throws IOException { validate(); log.info("Building tar: " + destFile); TarArchiveOutputStream tarStream = null; try { destFile.getAbsoluteFile().getParentFile().mkdirs(); GzipCompressorOutputStream gzipStream = new GzipCompressorOutputStream( new BufferedOutputStream(new FileOutputStream(destFile))); tarStream = new TarArchiveOutputStream(gzipStream, "UTF-8"); tarStream.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU); for (File sourceDir : sourceDirs) { for (File child : sourceDir.listFiles()) { addToTarRecursively(sourceDir, child, tarStream); } } } finally { if (tarStream != null) { tarStream.close(); } } } TarGzArchiver(); void setLog(Log log); void setDestFile(File destFile); void addDirectory(File directory); void createArchive(); }
TarGzArchiver { public void createArchive() throws IOException { validate(); log.info("Building tar: " + destFile); TarArchiveOutputStream tarStream = null; try { destFile.getAbsoluteFile().getParentFile().mkdirs(); GzipCompressorOutputStream gzipStream = new GzipCompressorOutputStream( new BufferedOutputStream(new FileOutputStream(destFile))); tarStream = new TarArchiveOutputStream(gzipStream, "UTF-8"); tarStream.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU); for (File sourceDir : sourceDirs) { for (File child : sourceDir.listFiles()) { addToTarRecursively(sourceDir, child, tarStream); } } } finally { if (tarStream != null) { tarStream.close(); } } } TarGzArchiver(); void setLog(Log log); void setDestFile(File destFile); void addDirectory(File directory); void createArchive();  }