Examples of TarArchiveEntry


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

    File archiveFile = new File(p.toUri().getPath() + ".tar");
    archiveFile.createNewFile();
    TarArchiveOutputStream out = new TarArchiveOutputStream(
        new FileOutputStream(archiveFile));
    TarArchiveEntry entry = new TarArchiveEntry(p.getName());
    entry.setSize(bytes.length);
    out.putArchiveEntry(entry);
    out.write(bytes);
    out.closeArchiveEntry();
    out.close();
View Full Code Here

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

      String token = getLast(Splitter.on("/").split(baseDir.getAbsolutePath()));
      TarArchiveOutputStream tos = new TarArchiveOutputStream(new FileOutputStream(tarFile));
      tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
      try {
         for (File file : files) {
            TarArchiveEntry tarEntry = new TarArchiveEntry(file);
            tarEntry.setName("/" + getLast(Splitter.on(token).split(file.toString())));
            tos.putArchiveEntry(tarEntry);
            if (!file.isDirectory()) {
               Files.asByteSource(file).copyTo(tos);
            }
            tos.closeArchiveEntry();
View Full Code Here

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

   private List<File> unTar(final File inputFile, final File outputDir) throws Exception {
      final List<File> untarredFiles = Lists.newArrayList();
      final InputStream is = new FileInputStream(inputFile);
      final TarArchiveInputStream tarArchiveInputStream = (TarArchiveInputStream)
              new ArchiveStreamFactory().createArchiveInputStream("tar", is);
      TarArchiveEntry entry;
      while ((entry = (TarArchiveEntry) tarArchiveInputStream.getNextEntry()) != null) {
         final File outputFile = new File(outputDir, entry.getName());
         if (entry.isDirectory()) {
            if (!outputFile.exists()) {
               if (!outputFile.mkdirs()) {
                  throw new IllegalStateException(String.format("Couldn't create directory %s.", outputFile.getAbsolutePath()));
               }
            }
View Full Code Here

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

    public static void read() throws Throwable {
        FileInputStream fis = new FileInputStream("C:\\X2.tgz");
        TarArchiveInputStream tis = new TarArchiveInputStream(new GZIPInputStream(fis));
        while (true) {
            TarArchiveEntry entry = tis.getNextTarEntry();
            if (entry == null)
                break;
            System.out.println(entry.getName());
        }
    }
View Full Code Here

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

            ZipArchiveEntry ze = null;
            byte[] schemaFile = null;
            while ((ze = zis.getNextZipEntry()) != null) {
                if (SOLR_TEMPLATE_SCHEMA.equals(ze.getName())) {
                    schemaFile = createSchemaXML(getLDPathProgram(ldPathProgram), IOUtils.toByteArray(zis));
                    TarArchiveEntry te = new TarArchiveEntry(coreName + SOLR_SCHEMA);
                    te.setSize(schemaFile.length);
                    tarOutputStream.putArchiveEntry(te);
                    tarOutputStream.write(schemaFile);
                    tarOutputStream.closeArchiveEntry();
                } else {
                    TarArchiveEntry te = new TarArchiveEntry(ze.getName().replaceAll(SOLR_TEMPLATE_NAME,
                        coreName));
                    te.setSize(ze.getSize());
                    tarOutputStream.putArchiveEntry(te);
                    tarOutputStream.write(IOUtils.toByteArray(zis));
                    tarOutputStream.closeArchiveEntry();
                }
View Full Code Here

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

            ZipArchiveEntry ze = null;
            byte[] schemaFile = null;
            while ((ze = zis.getNextZipEntry()) != null) {
                if (SOLR_TEMPLATE_SCHEMA.equals(ze.getName())) {
                    schemaFile = createSchemaXML(getLDPathProgram(ldPathProgram), IOUtils.toByteArray(zis));
                    TarArchiveEntry te = new TarArchiveEntry(coreName + SOLR_SCHEMA);
                    te.setSize(schemaFile.length);
                    tarOutputStream.putArchiveEntry(te);
                    tarOutputStream.write(schemaFile);
                    tarOutputStream.closeArchiveEntry();
                } else {
                    TarArchiveEntry te = new TarArchiveEntry(ze.getName().replaceAll(SOLR_TEMPLATE_NAME,
                        coreName));
                    te.setSize(ze.getSize());
                    tarOutputStream.putArchiveEntry(te);
                    tarOutputStream.write(IOUtils.toByteArray(zis));
                    tarOutputStream.closeArchiveEntry();
                }
View Full Code Here

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

        TarArchiveOutputStream tos = new TarArchiveOutputStream(cos);
        tos.setAddPaxHeadersForNonAsciiNames(true);
        tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);

        // add the Python script
        TarArchiveEntry pyEntry = new TarArchiveEntry("pt");
        pyEntry.setMode(FileMode.EXECUTABLE_FILE.getBits());
        pyEntry.setModTime(lastModified);
        pyEntry.setSize(pyBytes.length);
        tos.putArchiveEntry(pyEntry);
        tos.write(pyBytes);
        tos.closeArchiveEntry();

        // add a brief readme
        byte [] txtBytes = readAll(getClass().getResourceAsStream("/pt.txt"));
        TarArchiveEntry txtEntry = new TarArchiveEntry("README");
        txtEntry.setMode(FileMode.REGULAR_FILE.getBits());
        txtEntry.setModTime(lastModified);
        txtEntry.setSize(txtBytes.length);
        tos.putArchiveEntry(txtEntry);
        tos.write(txtBytes);
        tos.closeArchiveEntry();

        // cleanup
View Full Code Here

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

        }
        tw.getObjectId(id, 0);

        ObjectLoader loader = repository.open(id);
        if (FileMode.SYMLINK == mode) {
          TarArchiveEntry entry = new TarArchiveEntry(tw.getPathString(),TarArchiveEntry.LF_SYMLINK);
          ByteArrayOutputStream bos = new ByteArrayOutputStream();
          loader.copyTo(bos);
          entry.setLinkName(bos.toString());
          entry.setModTime(modified);
          tos.putArchiveEntry(entry);
          tos.closeArchiveEntry();
        } else {
          TarArchiveEntry entry = new TarArchiveEntry(tw.getPathString());
          entry.setMode(mode.getBits());
          entry.setModTime(modified);
          entry.setSize(loader.getSize());
          tos.putArchiveEntry(entry);
          loader.copyTo(tos);
          tos.closeArchiveEntry();
        }
      }
View Full Code Here

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

    {
        TarArchiveInputStream tis = null;
        try
        {
            tis = new TarArchiveInputStream(compressedData.getInputStream());
            TarArchiveEntry entry = null;

            Sequence results = new ValueSequence();

            while((entry = tis.getNextTarEntry()) != null)
            {
                Sequence processCompressedEntryResults = processCompressedEntry(entry.getName(), entry.isDirectory(), tis, filterParam, storeParam);

                results.addAll(processCompressedEntryResults);
            }

            return results;
View Full Code Here

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

    }

    @Override
    protected Object newEntry(String name)
    {
            return new TarArchiveEntry(name);
    }
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.