Examples of TarArchiveEntry


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

    final List<File> untaredFiles = new LinkedList<File>();
    final InputStream is = new FileInputStream(inputFile);
    final TarArchiveInputStream debInputStream = (TarArchiveInputStream) new ArchiveStreamFactory()
        .createArchiveInputStream("tar", is);
    TarArchiveEntry entry = null;
    while ((entry = (TarArchiveEntry) debInputStream.getNextEntry()) != null) {
      final File outputFile = new File(outputDir, entry.getName());
      if (entry.isDirectory()) {
        LOG.info(String.format(
            "Attempting to write output directory %s.", outputFile
                .getAbsolutePath()));
        if (!outputFile.exists()) {
          LOG.info(String.format(
View Full Code Here

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

    File gzipFile = new File(p.toUri().getPath() + ".tar.gz");
    gzipFile.createNewFile();
    TarArchiveOutputStream out = new TarArchiveOutputStream(
        new GZIPOutputStream(new FileOutputStream(gzipFile)));
    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

          OutputStream outputStream = new FileOutputStream( new File( archive) );         
          ArchiveOutputStream os = new ArchiveStreamFactory().createArchiveOutputStream("tar", outputStream);
         
      if (files != null) {
        for (File file: files) {
              final TarArchiveEntry entry = new TarArchiveEntry("testdata/test1.xml");
              entry.setModTime(0);
              entry.setSize(file.length());
              entry.setUserId(0);
              entry.setGroupId(0);
              entry.setMode(0100000);
              os.putArchiveEntry(entry);
              IOUtils.copy(new FileInputStream(file), os);
        }
      }
          os.closeArchiveEntry();
View Full Code Here

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

    // put the jar files under the archive in the classpath
    try {
      final InputStream is = new FileInputStream(archiveFile);
      final TarArchiveInputStream debInputStream =
          (TarArchiveInputStream) new ArchiveStreamFactory().createArchiveInputStream("tar", is);
      TarArchiveEntry entry = null;
      while ((entry = (TarArchiveEntry) debInputStream.getNextEntry()) != null) {
        if (entry.isFile()) {
          classpath.append(File.pathSeparatorChar);
          classpath.append("./" + serviceName + "/" + entry.getName());
        }
      }
      debInputStream.close();

    } catch (Exception e) {
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

            });
        setEntryBuilder(
              new ArchiveBase.EntryBuilder() {
                public ArchiveEntry buildEntry(ArchiveBase.ResourceWithFlags r) {
                    boolean isDir = r.getResource().isDirectory();
                    TarArchiveEntry ent =
                        new TarArchiveEntry(r.getName(),
                                            isDir ? TarConstants.LF_DIR
                                            : TarConstants.LF_NORMAL);
                    ent.setModTime(round(r.getResource().getLastModified(),
                                         1000));
                    ent.setSize(isDir ? 0 : r.getResource().getSize());

                    if (!isDir && r.getCollectionFlags().hasModeBeenSet()) {
                        ent.setMode(r.getCollectionFlags().getMode());
                    } else if (isDir
                               && r.getCollectionFlags().hasDirModeBeenSet()) {
                        ent.setMode(r.getCollectionFlags().getDirMode());
                    } else if (r.getResourceFlags().hasModeBeenSet()) {
                        ent.setMode(r.getResourceFlags().getMode());
                    } else {
                        ent.setMode(isDir
                                    ? ArchiveFileSet.DEFAULT_DIR_MODE
                                    : ArchiveFileSet.DEFAULT_FILE_MODE);
                    }

                    if (r.getResourceFlags().hasUserIdBeenSet()) {
                        ent.setUserId(r.getResourceFlags().getUserId());
                    } else if (r.getCollectionFlags().hasUserIdBeenSet()) {
                        ent.setUserId(r.getCollectionFlags().getUserId());
                    }

                    if (r.getResourceFlags().hasGroupIdBeenSet()) {
                        ent.setGroupId(r.getResourceFlags().getGroupId());
                    } else if (r.getCollectionFlags().hasGroupIdBeenSet()) {
                        ent.setGroupId(r.getCollectionFlags().getGroupId());
                    }
                    if (r.getResourceFlags().hasUserNameBeenSet()) {
                        ent.setUserName(r.getResourceFlags().getUserName());
                    } else if (r.getCollectionFlags().hasUserNameBeenSet()) {
                        ent.setUserName(r.getCollectionFlags().getUserName());
                    }

                    if (r.getResourceFlags().hasGroupNameBeenSet()) {
                        ent.setGroupName(r.getResourceFlags().getGroupName());
                    } else if (r.getCollectionFlags().hasGroupNameBeenSet()) {
                        ent.setGroupName(r.getCollectionFlags().getGroupName());
                    }
                    return ent;
                }
            });
View Full Code Here

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

  }

  private static void addFile(TarArchiveOutputStream tarOutputStream, String path, String base) throws IOException {
    File file = new File(path);
    String entryName = base + file.getName();
    TarArchiveEntry tarEntry = new TarArchiveEntry(file, entryName);

    tarOutputStream.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
    tarOutputStream.putArchiveEntry(tarEntry);

    if (file.isFile()) {
View Full Code Here

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

    }

    protected void setEntry(ArchiveEntry e) {
        super.setEntry(e);
        if (e != null) {
            TarArchiveEntry te = (TarArchiveEntry) e;
            userName = te.getUserName();
            groupName = te.getGroupName();
        }
    }
View Full Code Here

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

        return suite;
    }

    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
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.