Examples of TarArchiveEntry


Examples of com.dotcms.repackage.org.apache.commons.compress.archivers.tar.TarArchiveEntry

          // Create an entry for the file
          if(!dir.equals("."))
            if(File.separator.equals("\\")){
              dir = dir.replaceAll("\\\\", "/");
            }
            taos.putArchiveEntry(new TarArchiveEntry(file, dir + "/" + file.getName()));
        if (file.isFile()) {
              // Add the file to the archive
          BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
          IOUtils.copy(new FileInputStream(file), taos);
          taos.closeArchiveEntry();
View Full Code Here

Examples of com.facebook.presto.hive.shaded.org.apache.commons.compress.archivers.tar.TarArchiveEntry

      TarArchiveOutputStream tOut = new TarArchiveOutputStream(
          new GzipCompressorOutputStream(new BufferedOutputStream(out)));

      for (int i = 0; i < inputFiles.length; i++) {
        File f = new File(parentDir, inputFiles[i]);
        TarArchiveEntry tarEntry = new TarArchiveEntry(f, f.getName());
        tOut.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
        tOut.putArchiveEntry(tarEntry);
        FileInputStream input = new FileInputStream(f);
        try {
          IOUtils.copy(input, tOut); // copy with 8K buffer, not 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

            try {
                TarArchiveOutputStream outTarStream =
                    (TarArchiveOutputStream)new ArchiveStreamFactory()
                    .createArchiveOutputStream(ArchiveStreamFactory.TAR, outTarFileStream);
                // Create archive contents
                TarArchiveEntry tarArchiveEntry = new TarArchiveEntry(name + ".txt");
                tarArchiveEntry.setSize(fileSize);

                outTarStream.putArchiveEntry(tarArchiveEntry);
                for(long i = 0; i < fileSize; i+= ba_1k.length) {
                    outTarStream.write(ba_1k);
                }
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

    if(logMINOR) Logger.minor(this, "Create a TAR Bucket");
   
    TarArchiveOutputStream tarOS = new TarArchiveOutputStream(os);
    try {
      tarOS.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
      TarArchiveEntry ze;

      for (ContainerElement ph : containerItems) {
        if (logMINOR)
          Logger.minor(this, "Putting into tar: " + ph + " data length " + ph.data.size() + " name " + ph.targetInArchive);
        ze = new TarArchiveEntry(ph.targetInArchive);
        ze.setModTime(0);
        long size = ph.data.size();
        ze.setSize(size);
        tarOS.putArchiveEntry(ze);
        BucketTools.copyTo(ph.data, tarOS, size);
        tarOS.closeArchiveEntry();
      }
    } finally {
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

   * (you don't want to show your local server paths in the generated files)
   * @throws IOException - in case a file cannot be read
   */
  public static void addFileToTar(final TarArchiveOutputStream stream, final File file, final String name)
      throws IOException {
    TarArchiveEntry tarEntry = new TarArchiveEntry(file, name);
    stream.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
    stream.putArchiveEntry(tarEntry);
    if (file.isFile()) {
      IOUtils.copy(new FileInputStream(file), stream);
      stream.closeArchiveEntry();
View Full Code Here

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

                    if (isDir && !name.endsWith("/")) {
                        name += "/";
                    } else if (!isDir && name.endsWith("/")) {
                        name = name.substring(0, name.length() - 1);
                    }
                    TarArchiveEntry ent =
                        new TarArchiveEntry(name, getPreserveLeadingSlashes());
                    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

    }

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