Examples of TarEntry


Examples of org.apache.tools.tar.TarEntry

   
    /**
     * Outputs the differences found between the archive and the file system.
     */
    private void diff() throws IOException {
        TarEntry entry;
        InputStream in = null;
        TarInputStream tin;
        File file;
       
        if ((in = openFileRead(archive)) == null) {
            exit(1);
        }
       
        if (decompress != 0) {
            in = wrapInputStream(in);
        }
        tin = new TarInputStream(in);
       
        while ((entry = tin.getNextEntry()) != null) {
            file = new File(entry.getName());
           
            if (!file.exists()) {
                out(file + ": Warning: No such file or directory");
                continue;
            }
           
            if (file.lastModified() != entry.getModTime().getTime()) {
                out(file + ": Mod time is different");
            }
           
            if (file.length() != entry.getSize()) {
                out(file + ": Size is different");
            }
           
            // TODO check file mode
            // TODO check file ownership
View Full Code Here

Examples of org.apache.tools.tar.TarEntry

     * and to copy entries from another archive into another archive.
     *
     * FIXME does not verify that tin is actually a tar archive (Concat)
     */
    private void copy(TarInputStream tin, TarOutputStream tout) throws IOException {
        TarEntry entry;
        while ((entry = tin.getNextEntry()) != null) {
            tout.putNextEntry(entry);
            tin.copyEntryContents(tout);
            tout.closeEntry();
        }
View Full Code Here

Examples of org.apache.tools.tar.TarEntry

     */
    protected void fillMapsFromArchive(Resource src, String encoding,
            Map<String, Resource> fileEntries, Map<String, Resource> matchFileEntries,
            Map<String, Resource> dirEntries, Map<String, Resource> matchDirEntries) {

        TarEntry entry = null;
        TarInputStream ti = null;

        try {
            try {
                ti = new TarInputStream(src.getInputStream());
            } catch (IOException ex) {
                throw new BuildException("problem opening " + srcFile, ex);
            }
            while ((entry = ti.getNextEntry()) != null) {
                Resource r = new TarResource(src, entry);
                String name = entry.getName();
                if (entry.isDirectory()) {
                    name = trimSeparator(name);
                    dirEntries.put(name, r);
                    if (match(name)) {
                        matchDirEntries.put(name, r);
                    }
View Full Code Here

Examples of org.apache.tools.tar.TarEntry

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

        TarEntry te = new TarEntry(vPath, preserveLeadingSlashes);
        te.setModTime(r.getLastModified());
        // preserve permissions
        if (r instanceof ArchiveResource) {
            ArchiveResource ar = (ArchiveResource) r;
            te.setMode(ar.getMode());
            if (r instanceof TarResource) {
                TarResource tr = (TarResource) r;
                te.setUserName(tr.getUserName());
                te.setUserId(tr.getUid());
                te.setGroupName(tr.getGroup());
                te.setGroupId(tr.getGid());
            }
        }

        if (!r.isDirectory()) {
            if (r.size() > TarConstants.MAXSIZE) {
                throw new BuildException(
                    "Resource: " + r + " larger than "
                    + TarConstants.MAXSIZE + " bytes.");
            }
            te.setSize(r.getSize());
            // override permissions if set explicitly
            if (tarFileSet != null && tarFileSet.hasFileModeBeenSet()) {
                te.setMode(tarFileSet.getMode());
            }
        } else if (tarFileSet != null && tarFileSet.hasDirModeBeenSet()) {
            // override permissions if set explicitly
            te.setMode(tarFileSet.getDirMode(this.getProject()));
        }

        if (tarFileSet != null) {
            // only override permissions if set explicitly
            if (tarFileSet.hasUserNameBeenSet()) {
                te.setUserName(tarFileSet.getUserName());
            }
            if (tarFileSet.hasGroupBeenSet()) {
                te.setGroupName(tarFileSet.getGroup());
            }
            if (tarFileSet.hasUserIdBeenSet()) {
                te.setUserId(tarFileSet.getUid());
            }
            if (tarFileSet.hasGroupIdBeenSet()) {
                te.setGroupId(tarFileSet.getGid());
            }
        }

        InputStream in = null;
        try {
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

        }
    }

    protected void untar(File destDir, InputStream inputStream) throws IOException {
        TarInputStream tin = new TarInputStream(inputStream);
        TarEntry tarEntry = null;

        while ((tarEntry = tin.getNextEntry()) != null) {
            File destEntry = new File(destDir, tarEntry.getName());
            File parent = destEntry.getParentFile();

            if (!parent.exists()) {
                parent.mkdirs();
            }

            if (tarEntry.isDirectory()) {
                destEntry.mkdirs();
            } else {
                FileOutputStream fout = new FileOutputStream(destEntry);
                try {
                    tin.copyEntryContents(fout);
View Full Code Here

Examples of org.apache.tools.tar.TarEntry

                String path = relative + file.getName();

                if (file.isDirectory()) {
                    tarDir(path + File.separator, file, tos);
                } else {
                    TarEntry entry = new TarEntry(path);

                    entry.setMode(TarEntry.DEFAULT_FILE_MODE);
                    entry.setSize(file.length());
                    entry.setModTime(file.lastModified());

                    tos.putNextEntry(entry);

                    copyFile(file, tos);
View Full Code Here

Examples of org.apache.tools.tar.TarEntry

        final Progress progress
    ) {
        if (archiveIS instanceof TarInputStream) {
            TarInputStream tis = (TarInputStream) archiveIS;
            try {
                TarEntry te;
                while (!progress.isCanceled() && (te = tis.getNextEntry()) != null) {
                    if (!te.isDirectory()) {
                        String fileName2 = te.getName();
                        File file2 = allocateFile(rawDataDir, fileName2);
                       
                        progress.setProgress("Extracting " + fileName2, -1);
                       
                        JSONObject fileRecord2 = new JSONObject();
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

     * patterns and didn't match any exclude patterns.
     */
    protected void fillMapsFromArchive(Resource src, String encoding,
                                       Map fileEntries, Map matchFileEntries,
                                       Map dirEntries, Map matchDirEntries) {
        TarEntry entry = null;
        TarInputStream ti = null;

        try {
            try {
                ti = new TarInputStream(src.getInputStream());
            } catch (IOException ex) {
                throw new BuildException("problem opening " + srcFile, ex);
            }
            while ((entry = ti.getNextEntry()) != null) {
                Resource r = new TarResource(src, entry);
                String name = entry.getName();
                if (entry.isDirectory()) {
                    name = trimSeparator(name);
                    dirEntries.put(name, r);
                    if (match(name)) {
                        matchDirEntries.put(name, r);
                    }
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.