Examples of TarOutputStream


Examples of com.ice.tar.TarOutputStream

            // Set the streams up.
            OutputStream outStream = new FileOutputStream(tarDestFile);
            if (gzipIt) {
                outStream = new GZIPOutputStream(outStream);
            }
            TarOutputStream tarOutStream = new TarOutputStream(outStream);

            // Step through all of the files.
            for (int i=0; i < fileHolder.selectedFileList.size(); i++){

                File selectedFile = fileHolder.selectedFileList.get(i);

                // This is set in case the manager kills the processor and
                // wants to log the file that was being processed.
                super.currentObjBeingProcessed = selectedFile;

                // Instance variable used so the "cleanUp()" method can
                // close this stream.
                this.inStream = new FileInputStream(selectedFile);
                TarEntry tarEntry = null;
                try {
                    tarEntry = new TarEntry(selectedFile, selectedFile.getName());
                } catch (InvalidHeaderException e) {
                    errEntry.setThrowable(e);
                    errEntry.setAppContext("tar()");
                    errEntry.setAppMessage("Error tar'ing: " + selectedFile);
                    logger.logError(errEntry);
                }

                tarOutStream.putNextEntry(tarEntry);
                while((bytes_read = inStream.read(buffer)) != -1) {
                    tarOutStream.write(buffer,0,bytes_read);
                }
                tarOutStream.closeEntry();
                inStream.close();

                // Restart the wait period (so if the time to send a single
                // file is too long the processor is killed).
                super.processorSyncFlag.restartWaitUntilFalse();
            }
            tarOutStream.close();

        } catch (Exception e) {
            errEntry.setThrowable(e);
            errEntry.setAppContext("tar()");
            errEntry.setAppMessage("Error tar'ing: " + tarDestFile);
View Full Code Here

Examples of hudson.org.apache.tools.tar.TarOutputStream

final class TarArchiver extends Archiver {
    private final byte[] buf = new byte[8192];
    private final TarOutputStream tar;

    TarArchiver(OutputStream out) {
        tar = new TarOutputStream(new BufferedOutputStream(out) {
            // TarOutputStream uses TarBuffer internally,
            // which flushes the stream for each block. this creates unnecessary
            // data stream fragmentation, and flush request to a remote, which slows things down.
            @Override
            public void flush() throws IOException {
View Full Code Here

Examples of hudson.org.apache.tools.tar.TarOutputStream

final class TarArchiver extends Archiver {
    private final byte[] buf = new byte[8192];
    private final TarOutputStream tar;

    TarArchiver(OutputStream out) {
        tar = new TarOutputStream(new BufferedOutputStream(out) {
            // TarOutputStream uses TarBuffer internally,
            // which flushes the stream for each block. this creates unnecessary
            // data stream fragmentation, and flush request to a remote, which slows things down.
            @Override
            public void flush() throws IOException {
View Full Code Here

Examples of org.apache.activemq.console.command.store.tar.TarOutputStream

    TarOutputStream stream;

    ExportStreamManager(OutputStream target, int version) throws IOException {
        this.target = target;
        this.version = version;
        stream = new TarOutputStream(new GZIPOutputStream(target));
        store("ver", new AsciiBuffer(""+version));
    }
View Full Code Here

Examples of org.apache.tools.tar.TarOutputStream

                    outStr.write('B');
                    outStr.write('Z');
                    outStr = new CBZip2OutputStream(outStr);
                    break;
            }
            tarOutStr = new TarOutputStream(outStr);
            tarOutStr.setLongFileMode(TarOutputStream.LONGFILE_GNU);
        } catch (Exception e) {
            throw new GradleException(String.format("Could not create TAR '%s'.", tarFile), e);
        }
    }
View Full Code Here

Examples of org.apache.tools.tar.TarOutputStream

    setupDirs();
   
    // make a simple tar:
    final File simpleTar = new File(del, FILE);
    OutputStream os = new FileOutputStream(simpleTar);
    TarOutputStream tos = new TarOutputStream(os);
    try {
      TarEntry te = new TarEntry("foo");
      byte[] data = "some-content".getBytes("UTF-8");
      te.setSize(data.length);
      tos.putNextEntry(te);
      tos.write(data);
      tos.closeEntry();
      tos.flush();
      tos.finish();
    } finally {
      tos.close();
    }

    // successfully untar it into an existing dir:
    FileUtil.unTar(simpleTar, tmp);
    // check result:
View Full Code Here

Examples of org.apache.tools.tar.TarOutputStream

                return;
            }

            log("Building tar: " + tarFile.getAbsolutePath(), Project.MSG_INFO);

            TarOutputStream tOut = null;
            try {
                tOut = new TarOutputStream(
                    compression.compress(
                        new BufferedOutputStream(
                            new FileOutputStream(tarFile))));
                tOut.setDebug(true);
                if (longFileMode.isTruncateMode()) {
                    tOut.setLongFileMode(TarOutputStream.LONGFILE_TRUNCATE);
                } else if (longFileMode.isFailMode()
                            || longFileMode.isOmitMode()) {
                    tOut.setLongFileMode(TarOutputStream.LONGFILE_ERROR);
                } else {
                    // warn or GNU
                    tOut.setLongFileMode(TarOutputStream.LONGFILE_GNU);
                }

                longWarningGiven = false;
                for (Enumeration e = filesets.elements();
                     e.hasMoreElements();) {
View Full Code Here

Examples of org.apache.tools.tar.TarOutputStream

                return;
            }

            log("Building tar: " + tarFile.getAbsolutePath(), Project.MSG_INFO);

            TarOutputStream tOut = null;
            try {
                tOut = new TarOutputStream(
                    compression.compress(
                        new BufferedOutputStream(
                            new FileOutputStream(tarFile))));
                tOut.setDebug(true);
                if (longFileMode.isTruncateMode()) {
                    tOut.setLongFileMode(TarOutputStream.LONGFILE_TRUNCATE);
                } else if (longFileMode.isFailMode() ||
                         longFileMode.isOmitMode()) {
                    tOut.setLongFileMode(TarOutputStream.LONGFILE_ERROR);
                } else {
                    // warn or GNU
                    tOut.setLongFileMode(TarOutputStream.LONGFILE_GNU);
                }

                longWarningGiven = false;
                for (Enumeration e = filesets.elements();
                     e.hasMoreElements();) {
                    TarFileSet fs = (TarFileSet) e.nextElement();
                    String[] files = fs.getFiles(project);
                    if (files.length > 1 && fs.getFullpath().length() > 0) {
                        throw new BuildException("fullpath attribute may only "
                                                 + "be specified for "
                                                 + "filesets that specify a "
                                                 + "single file.");
                    }
                    for (int i = 0; i < files.length; i++) {
                        File f = new File(fs.getDir(project), files[i]);
                        String name = files[i].replace(File.separatorChar, '/');
                        tarFile(f, tOut, name, fs);
                    }
                }
            } catch (IOException ioe) {
                String msg = "Problem creating TAR: " + ioe.getMessage();
                throw new BuildException(msg, ioe, location);
            } finally {
                if (tOut != null) {
                    try {
                        // close up
                        tOut.close();
                    } catch (IOException e) {}
                }
            }
        } finally {
            filesets = savedFileSets;
View Full Code Here

Examples of org.apache.tools.tar.TarOutputStream

                return;
            }

            log("Building tar: " + tarFile.getAbsolutePath(), Project.MSG_INFO);

            TarOutputStream tOut = null;
            try {
                tOut = new TarOutputStream(
                    compression.compress(
                        new BufferedOutputStream(
                            new FileOutputStream(tarFile))));
                tOut.setDebug(true);
                if (longFileMode.isTruncateMode()) {
                    tOut.setLongFileMode(TarOutputStream.LONGFILE_TRUNCATE);
                } else if (longFileMode.isFailMode()
                            || longFileMode.isOmitMode()) {
                    tOut.setLongFileMode(TarOutputStream.LONGFILE_ERROR);
                } else {
                    // warn or GNU
                    tOut.setLongFileMode(TarOutputStream.LONGFILE_GNU);
                }

                longWarningGiven = false;
                for (Enumeration e = filesets.elements();
                     e.hasMoreElements();) {
                    TarFileSet fs = (TarFileSet) e.nextElement();
                    String[] files = fs.getFiles(getProject());
                    if (files.length > 1 && fs.getFullpath().length() > 0) {
                        throw new BuildException("fullpath attribute may only "
                                                 + "be specified for "
                                                 + "filesets that specify a "
                                                 + "single file.");
                    }
                    for (int i = 0; i < files.length; i++) {
                        File f = new File(fs.getDir(getProject()), files[i]);
                        String name = files[i].replace(File.separatorChar, '/');
                        tarFile(f, tOut, name, fs);
                    }
                }
            } catch (IOException ioe) {
                String msg = "Problem creating TAR: " + ioe.getMessage();
                throw new BuildException(msg, ioe, getLocation());
            } finally {
                if (tOut != null) {
                    try {
                        // close up
                        tOut.close();
                    } catch (IOException e) {
                        // ignore
                    }
                }
            }
View Full Code Here

Examples of org.apache.tools.tar.TarOutputStream

     *      on it, and verified before exiting. If the archive is bad, the original is restored.
     */
    private void concat(File[] archives) throws IOException {
        InputStream in;
        TarInputStream tin;
        TarOutputStream tout;
       
        // Setup archive for appending
        tout = appendTarOutputStream();
       
        // Concatenate new archives
        for (File arch : archives) {
            if ((in = openFileRead(arch)) == null) {
                continue;
            }
            bzip = gzip = false;
            decompress = checkCompressed(arch);
            if (decompress != 0) {
                in = wrapInputStream(in);
            }
            tin = new TarInputStream(in);
            copy(tin, tout);
        }
        tout.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.