Package org.apache.tools.tar

Examples of org.apache.tools.tar.TarEntry


    @Override
    public void analyze(Document doc, InputStream in) throws IOException {
        content.setLength(0);

        TarInputStream zis = new TarInputStream(in);
        TarEntry entry;
        while ((entry = zis.getNextEntry()) != null) {
            content.append(entry.getName()).append('\n');
        }
        content.trimToSize();
        doc.add(new Field("full", dummy));
    }
View Full Code Here


        if (entry.getName().length() >= TarConstants.NAMELEN) {

            if (longFileMode == LONGFILE_GNU) {
                // create a TarEntry for the LongLink, the contents
                // of which are the entry's name
                TarEntry longLinkEntry = new TarEntry(TarConstants.GNU_LONGLINK,
                                                      TarConstants.LF_GNUTYPE_LONGNAME);

                byte[] name = entry.getName().getBytes("UTF-8");
                longLinkEntry.setSize(name.length + 1);
                putNextEntry(longLinkEntry);
                write(name);
                write(0);
                closeEntry();
            } else if (longFileMode != LONGFILE_TRUNCATE) {
View Full Code Here

     * 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();

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

        tar.setLongFileMode(TarOutputStream.LONGFILE_GNU);
    }

    @Override
    public void visitSymlink(File link, String target, String relativePath) throws IOException {
        TarEntry e = new TarEntry(relativePath, LF_SYMLINK);

        try {
            StringBuffer linkName = (StringBuffer) LINKNAME_FIELD.get(e);
            linkName.setLength(0);
            linkName.append(target);
View Full Code Here

        if(Functions.isWindows())
            relativePath = relativePath.replace('\\','/');

        if(file.isDirectory())
            relativePath+='/';
        TarEntry te = new TarEntry(relativePath);
        te.setModTime(file.lastModified());
        if(!file.isDirectory())
            te.setSize(file.length());

        tar.putNextEntry(te);

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

TOP

Related Classes of org.apache.tools.tar.TarEntry

Copyright © 2018 www.massapicom. 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.