Examples of TarEntry


Examples of org.apache.tools.tar.TarEntry

        }

        if (this.hasHitEOF) {
            this.currEntry = null;
        } else {
            this.currEntry = new TarEntry(headerBuf);

            if (this.debug) {
                System.err.println("TarInputStream: SET CURRENTRY '"
                        + this.currEntry.getName()
                        + "' size = "
View Full Code Here

Examples of org.apache.tools.tar.TarEntry

     * Reads from a tar stream and stores obtained files to the base dir.
     */
    private static void readFromTar(String name, File baseDir, InputStream in) throws IOException {
        TarInputStream t = new TarInputStream(in);
        try {
            TarEntry te;
            while ((te = t.getNextEntry()) != null) {
                File f = new File(baseDir,te.getName());
                if(te.isDirectory()) {
                    f.mkdirs();
                } else {
                    File parent = f.getParentFile();
                    if (parent != null) parent.mkdirs();

                    byte linkFlag = (Byte) LINKFLAG_FIELD.get(te);
                    if (linkFlag==TarEntry.LF_SYMLINK) {
                        new FilePath(f).symlinkTo(te.getLinkName(), TaskListener.NULL);
                    } else {
                        IOUtils.copy(t,f);

                        f.setLastModified(te.getModTime().getTime());
                        int mode = te.getMode()&0777;
                        if(mode!=0 && !Functions.isWindows()) // be defensive
                            _chmod(f,mode);
                    }
                }
            }
View Full Code Here

Examples of org.apache.tools.tar.TarEntry

                        "Entry: " + vPath + " longer than " +
                        TarConstants.NAMELEN + "characters.", location);
                }
            }

            TarEntry te = new TarEntry(vPath);
            te.setModTime(file.lastModified());
            if (!file.isDirectory()) {
                te.setSize(file.length());
                te.setMode(tarFileSet.getMode());
            }
            te.setUserName(tarFileSet.getUserName());
            te.setGroupName(tarFileSet.getGroup());

            tOut.putNextEntry(te);

            if (!file.isDirectory()) {
                fIn = new FileInputStream(file);
View Full Code Here

Examples of org.apache.tools.tar.TarEntry

            log("Expanding: " + srcF + " into " + dir, Project.MSG_INFO);
            tis = new TarInputStream(
                compression.decompress(srcF,
                    new BufferedInputStream(
                        new FileInputStream(srcF))));
            TarEntry te = null;

            while ((te = tis.getNextEntry()) != null) {
                extractFile(fileUtils, srcF, dir, tis,
                            te.getName(), te.getModTime(), te.isDirectory());
            }
            log("expand complete", Project.MSG_VERBOSE);

        } catch (IOException ioe) {
            throw new BuildException("Error while expanding " + srcF.getPath(),
View Full Code Here

Examples of org.apache.tools.tar.TarEntry

                        + " longer than " + TarConstants.NAMELEN
                        + "characters.", getLocation());
                }
            }

            TarEntry te = new TarEntry(vPath);
            te.setModTime(file.lastModified());
            if (!file.isDirectory()) {
                te.setSize(file.length());
                te.setMode(tarFileSet.getMode());
            } else {
                te.setMode(tarFileSet.getDirMode());
            }
            te.setUserName(tarFileSet.getUserName());
            te.setGroupName(tarFileSet.getGroup());

            tOut.putNextEntry(te);

            if (!file.isDirectory()) {
                fIn = new FileInputStream(file);
View Full Code Here

Examples of org.apache.tools.tar.TarEntry

            log("Expanding: " + srcF + " into " + dir, Project.MSG_INFO);
            tis = new TarInputStream(
                compression.decompress(srcF,
                    new BufferedInputStream(
                        new FileInputStream(srcF))));
            TarEntry te = null;

            while ((te = tis.getNextEntry()) != null) {
                extractFile(fileUtils, srcF, dir, tis,
                            te.getName(), te.getModTime(), te.isDirectory());
            }
            log("expand complete", Project.MSG_VERBOSE);

        } catch (IOException ioe) {
            throw new BuildException("Error while expanding " + srcF.getPath(),
View Full Code Here

Examples of org.apache.tools.tar.TarEntry

     */
    private void insert(File[] files) throws IOException {
        InputStream in;
        OutputStream out;
        TarOutputStream tout = null;
        TarEntry entry;
       
        if (mode == TAR_APPEND && archive.exists()) {
            tout = appendTarOutputStream();
        } else {
            createArchive();
            if ((out = openFileWrite(archive, false, false)) == null) {
                fatal(" ", 1);
            }
            if (compress != 0) {
                out = wrapOutputStream(out);
            }
            tout = new TarOutputStream(out);
        }
       
        // Insert new entries
        for (File file : files) {
            notice(file.getPath());
            entry = new TarEntry(file);
            tout.putNextEntry(entry);
           
            if (!file.isDirectory()) {
                if ((in = openFileRead(file)) == null) continue;
                processStream(in, tout);
View Full Code Here

Examples of org.apache.tools.tar.TarEntry

   
    // TODO
    private void update(File[] files) throws IOException {
        InputStream in;
        TarInputStream tin;
        TarEntry entry;
        TreeMap<String, Long> entries = new TreeMap<String, Long>();
       
        if ((in = openFileRead(archive)) == null) {
            fatal(" ", 1);
        }
        if (decompress != 0) {
            in = wrapInputStream(in);
        }
       
        tin = new TarInputStream(in);
       
        while ((entry = tin.getNextEntry()) != null) {
            entries.put(entry.getName(), entry.getModTime().getTime());
        }
        tin.close();
       
        long etime, ftime;
        ArrayList<File> list = new ArrayList<File>();
View Full Code Here

Examples of org.apache.tools.tar.TarEntry

     * TODO Need to parse Path for choosing specific files/directories either by direct naming
     *      or by wildcard patterns.
     * TODO Read list of entries to extract from FileList if its set.
     */
    private void extract() throws IOException {
        TarEntry entry;
        InputStream in = null;
        OutputStream out;
        TarInputStream tin;
        File file;
       
        if (archive != null) {
            if ((in = openFileRead(archive)) == null) {
                fatal(" ", 1);
            }
        } else {
            in = stdin;
        }
       
        if (decompress != 0) {
            in = wrapInputStream(in);
        }
        tin = new TarInputStream(in);
       
        if (use_stdout) {
            out = stdout;
        }
       
        while ((entry = tin.getNextEntry()) != null) {
            notice(entry.getName());
            file = new File(entry.getName());
            if (entry.isDirectory()) {
                if (!file.exists()) {
                    file.mkdirs();
                }
                continue;
            } else {
                if (file.exists()) {
                    if (keepOld || (keepNew && (file.lastModified() >= entry.getModTime().getTime()))) {
                        continue;
                    }
                    if (backup) {
                        file.renameTo(new File(file.getPath() + suffix));
                    }
View Full Code Here

Examples of org.apache.tools.tar.TarEntry

     *
     * TODO Need to parse Path for choosing specific files/directories either by direct naming
     *      or by wildcard patterns.
     */
    private void list() throws IOException {
        TarEntry entry;
        InputStream in = null;
        TarInputStream tin;
       
        if ((in = openFileRead(archive)) == null) {
            fatal(" ", 1);
        }
       
        if (decompress != 0) {
            in = wrapInputStream(in);
        }
        tin = new TarInputStream(in);
       
        while ((entry = tin.getNextEntry()) != null) {
            out(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.