Examples of TarArchiveEntry


Examples of org.apache.commons.compress.archivers.tar.TarArchiveEntry

    String path = libZip.toURI().getPath();
    String outDir = Locations.getParent(libZip).toURI().getPath();
    TarArchiveInputStream archiveInputStream = new TarArchiveInputStream(
      new GZIPInputStream(new FileInputStream(path)));
    try {
      TarArchiveEntry entry = archiveInputStream.getNextTarEntry();
      while (entry != null) {
        File destFile = new File(outDir, entry.getName());
        destFile.getParentFile().mkdirs();
        if (!entry.isDirectory()) {
          ByteStreams.copy(archiveInputStream, Files.newOutputStreamSupplier(destFile));
          //TODO: Set executable permission based on entry.getMode()
          destFile.setExecutable(true, false);
        }
        entry = archiveInputStream.getNextTarEntry();
View Full Code Here

Examples of org.apache.commons.compress.archivers.tar.TarArchiveEntry

  private void untarTarFile(File tarFile, File destDir) throws Exception {
    TarArchiveInputStream tarInputStream = null;
    try {
      tarInputStream = new TarArchiveInputStream(new FileInputStream(tarFile));
      TarArchiveEntry entry = null;
      while ((entry = tarInputStream.getNextTarEntry()) != null) {
        String name = entry.getName();
        LOGGER.debug("Next file: " + name);
        File destFile = new File(destDir, entry.getName());
        if (entry.isDirectory()) {
          destFile.mkdirs();
          continue;
        }
        File destParent = destFile.getParentFile();
        destParent.mkdirs();
View Full Code Here

Examples of org.apache.commons.compress.archivers.tar.TarArchiveEntry

            ChangeSet changes = new ChangeSet();
            changes.delete("test2.xml");

            final File file1 = getFile("test.txt");

            final TarArchiveEntry entry = new TarArchiveEntry(
                    "testdata/test.txt");
            entry.setModTime(0);
            entry.setSize(file1.length());
            entry.setUserId(0);
            entry.setGroupId(0);
            entry.setUserName("avalon");
            entry.setGroupName("excalibur");
            entry.setMode(0100000);

            changes.add(entry, new FileInputStream(file1));

            final File input = getFile("bla.tar");
            final InputStream is = new FileInputStream(input);
View Full Code Here

Examples of org.apache.commons.compress.archivers.tar.TarArchiveEntry

public class ChainingTestCase extends AbstractTestCase {

    public void testTarGzip() throws Exception {
        File file = getFile("bla.tgz");
        final TarArchiveInputStream is = new TarArchiveInputStream(new GzipCompressorInputStream(new FileInputStream(file)));
        final TarArchiveEntry entry = (TarArchiveEntry)is.getNextEntry();
        assertNotNull(entry);
        assertEquals("test1.xml", entry.getName());
        is.close();
    }
View Full Code Here

Examples of org.apache.commons.compress.archivers.tar.TarArchiveEntry

    }

    public void testTarBzip2() throws Exception {
        File file = getFile("bla.tar.bz2");
        final TarArchiveInputStream is = new TarArchiveInputStream(new BZip2CompressorInputStream(new FileInputStream(file)));
        final TarArchiveEntry entry = (TarArchiveEntry)is.getNextEntry();
        assertNotNull(entry);
        assertEquals("test1.xml", entry.getName());
        is.close();
    }
View Full Code Here

Examples of org.apache.commons.compress.archivers.tar.TarArchiveEntry

    public void testWriteJar() throws Exception {
        ArchiveEntry entry = new JarArchiveEntry("dummy");
        compareWrites("jar", entry);
    }
    public void testWriteTar() throws Exception {
        TarArchiveEntry entry = new TarArchiveEntry("dummy");
        entry.setSize(bytesToTest);
        compareWrites("tar", entry);
    }
View Full Code Here

Examples of org.apache.commons.compress.archivers.tar.TarArchiveEntry

    }

    @Override
    protected String getExpectedString(ArchiveEntry entry) {
        if (entry instanceof TarArchiveEntry) {
            TarArchiveEntry tarEntry = (TarArchiveEntry) entry;
            if (tarEntry.isSymbolicLink()) {
                return tarEntry.getName() + " -> " + tarEntry.getLinkName();
            }
        }
        return entry.getName();
    }
View Full Code Here

Examples of org.apache.commons.compress.archivers.tar.TarArchiveEntry

            ChangeSet changes = new ChangeSet();
            changes.delete("test2.xml");

            final File file1 = getFile("test.txt");

            final TarArchiveEntry entry = new TarArchiveEntry(
                    "testdata/test.txt");
            entry.setModTime(0);
            entry.setSize(file1.length());
            entry.setUserId(0);
            entry.setGroupId(0);
            entry.setUserName("avalon");
            entry.setGroupName("excalibur");
            entry.setMode(0100000);

            changes.add(entry, new FileInputStream(file1));

            final File input = getFile("bla.tar");
            final InputStream is = new FileInputStream(input);
View Full Code Here

Examples of org.apache.commons.compress.archivers.tar.TarArchiveEntry

        } catch (IOException io) {
            // Exception expected
        }
       
        aos1 = factory.createArchiveOutputStream("tar", out1);
        aos1.putArchiveEntry(new TarArchiveEntry("dummy"));
        try {
            aos1.finish();
            fail("After putArchive should follow closeArchive");
        } catch (IOException io) {
            // Exception expected
View Full Code Here

Examples of org.apache.commons.compress.archivers.tar.TarArchiveEntry

    public void testTarArchiveCreation() throws Exception {
        final File output = new File(dir, "bla.tar");
        final File file1 = getFile("test1.xml");
        final OutputStream out = new FileOutputStream(output);
        final ArchiveOutputStream os = new ArchiveStreamFactory().createArchiveOutputStream("tar", out);
        final TarArchiveEntry entry = new TarArchiveEntry("testdata/test1.xml");
        entry.setModTime(0);
        entry.setSize(file1.length());
        entry.setUserId(0);
        entry.setGroupId(0);
        entry.setUserName("avalon");
        entry.setGroupName("excalibur");
        entry.setMode(0100000);
        os.putArchiveEntry(entry);
        IOUtils.copy(new FileInputStream(file1), os);
        os.closeArchiveEntry();
        os.close();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.