Examples of TarEntry


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

        try {
            log("Expanding: " + srcF + " into " + dir, Project.MSG_INFO);
            fis = new FileInputStream(srcF);
            tis = new TarInputStream(
                compression.decompress(srcF, new BufferedInputStream(fis)));
            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());
            te.setUserId(tarFileSet.getUid());
            te.setGroupId(tarFileSet.getGid());

            tOut.putNextEntry(te);

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

Examples of org.apache.tools.tar.TarEntry

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

        TarEntry te = new TarEntry(vPath);
        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

      tarIn = new TarInputStream(new GZIPInputStream
          new BufferedInputStream(new FileInputStream(file)))
          1024);         
     
      TarEntry entry = null;
            //tarIn.getNextEntry(); 
      //File outputDir = new File(outDir, "myBag");
      //outputDir.mkdirs();
      while( (entry = tarIn.getNextEntry()) != null ){ 
        File f = new File(outDir,entry.getName());
        if(entry.isDirectory()){
          f.mkdirs();
        }else{                    
          f.getParentFile().mkdirs();
          f.createNewFile();
          OutputStream out = null
View Full Code Here

Examples of org.apache.tools.tar.TarEntry

    // 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();
View Full Code Here

Examples of org.apache.tools.tar.TarEntry

    @Override
    public void analyze(Document doc, StreamSource src, Writer xrefOut) throws IOException {
        ArrayList<String> names = new ArrayList<>();

        try (TarInputStream zis = new TarInputStream(src.getStream())) {
            TarEntry entry;
            while ((entry = zis.getNextEntry()) != null) {
                String name = entry.getName();
                names.add(name);
                if (xrefOut != null) {
                    Util.htmlize(name, xrefOut);
                    xrefOut.append("<br/>");
                }
View Full Code Here

Examples of org.apache.tools.tar.TarEntry

        try {
            tis =
                new TarInputStream(compression.decompress(name,
                                                          new BufferedInputStream(stream)));
            log("Expanding: " + name + " into " + dir, Project.MSG_INFO);
            TarEntry te = null;
            boolean empty = true;
            FileNameMapper mapper = getMapper();
            while ((te = tis.getNextEntry()) != null) {
                empty = false;
                extractFile(FileUtils.getFileUtils(), null, dir, tis,
                            te.getName(), te.getModTime(),
                            te.isDirectory(), mapper);
            }
            if (empty && getFailOnEmptyArchive()) {
                throw new BuildException("archive '" + name + "' is empty");
            }
            log("expand complete", Project.MSG_VERBOSE);
View Full Code Here

Examples of org.apache.tools.tar.TarEntry

        if (isReference()) {
            return ((Resource) getCheckedRef()).getInputStream();
        }
        Resource archive = getArchive();
        final TarInputStream i = new TarInputStream(archive.getInputStream());
        TarEntry te = null;
        while ((te = i.getNextEntry()) != null) {
            if (te.getName().equals(getName())) {
                return i;
            }
        }

        FileUtils.close(i);
View Full Code Here

Examples of org.codehaus.plexus.archiver.tar.TarEntry

    private TarUtil() {
    }

    public static void untar(File source, File target, Log logger) {
        TarInputStream tarInput = null;
        TarEntry entry;
        OutputStream output = null;

        try {
            tarInput = new TarInputStream(new FileInputStream(source));

            entry = tarInput.getNextEntry();
            while (entry != null) {
                File outputFile = new File(target.getCanonicalPath() + File.separator + entry.getName());
                if (entry.isDirectory()) {
                    logger.debug("creating dir at: " + outputFile.getCanonicalPath());
                    outputFile.mkdirs();
                } else {
                    logger.debug("creating file at: " + outputFile.getCanonicalPath());
                    output = new FileOutputStream(outputFile);
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.