Java Zip Directory zipDirectoryEntry(ZipOutputStream output, IPath entry, long time, Set directoryEntries)

Here you can find the source of zipDirectoryEntry(ZipOutputStream output, IPath entry, long time, Set directoryEntries)

Description

zip Directory Entry

License

Open Source License

Declaration

private static void zipDirectoryEntry(ZipOutputStream output, IPath entry, long time,
            Set<IPath> directoryEntries) throws IOException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 *  Copyright (c) 2007, 2010 IBM Corporation and others.
 *  All rights reserved. This program and the accompanying materials
 *  are made available under the terms of the Eclipse Public License v1.0
 *  which accompanies this distribution, and is available at
 *  http://www.eclipse.org/legal/epl-v10.html
 * /*from  w w w  .  j av a2s  .  co  m*/
 *  Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

import java.io.*;
import java.util.*;

import java.util.zip.*;
import org.eclipse.core.runtime.*;

public class Main {
    private static void zipDirectoryEntry(ZipOutputStream output, IPath entry, long time,
            Set<IPath> directoryEntries) throws IOException {
        entry = entry.addTrailingSeparator();
        if (!directoryEntries.contains(entry)) {
            //make sure parent entries are in the zip
            if (entry.segmentCount() > 1)
                zipDirectoryEntry(output, entry.removeLastSegments(1), time, directoryEntries);

            try {
                ZipEntry dirEntry = new ZipEntry(entry.toString());
                dirEntry.setTime(time);
                output.putNextEntry(dirEntry);
                directoryEntries.add(entry);
            } catch (ZipException ze) {
                //duplicate entries shouldn't happen because we checked the set
            } finally {
                try {
                    output.closeEntry();
                } catch (IOException e) {
                    // ignore
                }
            }
        }
    }
}

Related

  1. zipDirectory(String dir2zip, ZipOutputStream zos, String zipPath)
  2. zipDirectory(String directoryName, int iBaseFolderLength, ZipOutputStream zos, CRC32 crc)
  3. zipDirectory(String directoryName, String targetName)
  4. zipDirectory(String dirName, String zipFileName)
  5. zipDirectory(ZipOutputStream out, String stripPath, File dir, char pathSeparator)
  6. zipDirectoryRecursive(File directory, String zipPath, ZipOutputStream zos, ArrayList avoidingFiles)
  7. zipSubDirectory(String basePath, File dir, ZipOutputStream zout)