Package org.apache.tools.zip

Examples of org.apache.tools.zip.ZipEntry


                    }
                });
            testInstance.execute();

            zf = new ZipFile(f);
            ZipEntry ze = zf.getEntry("x");
            assertNotNull(ze);
            assertEquals(1, ze.getExtraFields().length);
            assertTrue(ze.getExtraFields()[0] instanceof JarMarker);
        } finally {
            ZipFile.closeQuietly(zf);
            if (f.exists()) {
                f.delete();
            }
View Full Code Here


    public InputStream getInputStream() throws IOException {
        if (isReference()) {
            return ((Resource) getCheckedRef()).getInputStream();
        }
        final ZipFile z = new ZipFile(getZipfile(), getEncoding());
        ZipEntry ze = z.getEntry(getName());
        if (ze == null) {
            z.close();
            throw new BuildException("no entry " + getName() + " in "
                                     + getArchive());
        }
View Full Code Here

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

        File srcFile = null;
        FileProvider fp = (FileProvider) src.as(FileProvider.class);
        if (fp != null) {
            srcFile = fp.getFile();
        } else {
            throw new BuildException("Only file provider resources are supported");
        }

        try {
            try {
                zf = new ZipFile(srcFile, encoding);
            } catch (ZipException ex) {
                throw new BuildException("Problem reading " + srcFile, ex);
            } catch (IOException ex) {
                throw new BuildException("Problem opening " + srcFile, ex);
            }
            Enumeration e = zf.getEntries();
            while (e.hasMoreElements()) {
                entry = (ZipEntry) e.nextElement();
                Resource r = new ZipResource(srcFile, encoding, 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

            zf = new ZipFile(srcF, encoding, scanForUnicodeExtraFields);
            boolean empty = true;
            Enumeration e = zf.getEntries();
            while (e.hasMoreElements()) {
                empty = false;
                ZipEntry ze = (ZipEntry) e.nextElement();
                InputStream is = null;
                log("extracting " + ze.getName(), Project.MSG_DEBUG);
                try {
                    extractFile(fileUtils, srcF, dir,
                                is = zf.getInputStream(ze),
                                ze.getName(), new Date(ze.getTime()),
                                ze.isDirectory(), mapper);
                } finally {
                    FileUtils.close(is);
                }
            }
            if (empty && getFailOnEmptyArchive()) {
View Full Code Here

    Enumeration zList = zfile.getEntries();
    byte[] buf = new byte[1024];
    File tmpfile = null;
    File tmpfold = null;
    while (zList.hasMoreElements()) {
      ZipEntry ze = (ZipEntry) zList.nextElement();
      tmpfile = new File(toUnzipFold.getAbsolutePath() + File.separator
          + ze.getName());
      if (ze.isDirectory()) {
        continue;
      } else {
        tmpfold = tmpfile.getParentFile();
        if (!tmpfold.exists()) {
          tmpfold.mkdirs();
View Full Code Here

    List unZipFiles = new ArrayList();

    try {
      for (Enumeration enu = aZipFile.getEntries(); enu.hasMoreElements();) {

        ZipEntry ze = (ZipEntry) enu.nextElement();
        InputStream is = aZipFile.getInputStream(ze);

        StringBuilder sb = new StringBuilder(
            DOGlobals.getInstance().UPLOAD_TEMP).append(randomStr)
            .append(File.separator);
        File dirFile = new File(sb.toString());
        dirFile.mkdir();
        sb.append(ze.getName());
        File aFile = new File(sb.toString());
        aFile.createNewFile();
        FileOutputStream fos = new FileOutputStream(aFile);

        byte[] by = new byte[1024];
View Full Code Here

        }
      }
      // String aFileName = aInstance.getValue("APP_NAME");
      if (aInstance != null) {
        String id_applyid = aInstance.getValue("id_applyid");
        ZipEntry ze = new ZipEntry(id_applyid + ".xml");
        zos.putNextEntry(ze);
        zos.write(DODownLoadFile.outHtmlCode(paneModelUid).getBytes(
            "utf-8"));
        ze.clone();
      }
    }
    zos.close();
    return zipFilePath.toString();
View Full Code Here

    private int getUnixMode(Resource r, ZipFile zf, int defaultMode)
        throws IOException {

        int unixMode = defaultMode;
        if (zf != null) {
            ZipEntry ze = zf.getEntry(r.getName());
            unixMode = ze.getUnixMode();
            if ((unixMode == 0 || unixMode == UnixStat.DIR_FLAG)
                && !preserve0Permissions) {
                unixMode = defaultMode;
            }
        } else if (r instanceof ArchiveResource) {
View Full Code Here

                             ZipOutputStream zOut, int mode,
                             ZipFile zf, File fromArchive)
        throws IOException {

        if (zf != null) {
            ZipEntry ze = zf.getEntry(r.getName());

            if (ze != null) {
                boolean oldCompress = doCompress;
                if (keepCompression) {
                    doCompress = (ze.getMethod() == ZipEntry.DEFLATED);
                }
                InputStream is = null;
                try {
                    is = zf.getInputStream(ze);
                    zipFile(is, zOut, prefix + name, ze.getTime(),
                            fromArchive, mode, ze.getExtraFields());
                } finally {
                    doCompress = oldCompress;
                    FileUtils.close(is);
                }
            }
View Full Code Here

        logWhenWriting("adding directory " + vPath, Project.MSG_VERBOSE);
        addedDirs.put(vPath, vPath);

        if (!skipWriting) {
            ZipEntry ze = new ZipEntry (vPath);

            // ZIPs store time with a granularity of 2 seconds, round up
            int millisToAdd = roundUp ? ROUNDUP_MILLIS : 0;

            if (dir != null && dir.isExists()) {
                ze.setTime(dir.getLastModified() + millisToAdd);
            } else {
                ze.setTime(System.currentTimeMillis() + millisToAdd);
            }
            ze.setSize (0);
            ze.setMethod (ZipEntry.STORED);
            // This is faintly ridiculous:
            ze.setCrc (EMPTY_CRC);
            ze.setUnixMode(mode);

            if (extra != null) {
                ze.setExtraFields(extra);
            }

            zOut.putNextEntry(ze);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.tools.zip.ZipEntry

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.