|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.javacore.scanning; import java.io.File; import java.io.IOException; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; /** * * @author thurka */ class ZipArchiveInfo { ZipFile zipFile; Map directoryMap=new HashMap(1000); ZipDirInfo rootInfo; /** Creates a new instance of ZipArchiveInfo */ ZipArchiveInfo(File f) throws IOException { zipFile=new ZipFile(f); rootInfo=new ZipDirInfo("",""); } FileInfo getRootFileInfo() { Enumeration en=zipFile.entries(); while(en.hasMoreElements()) { ZipEntry entry=(ZipEntry)en.nextElement(); if (!entry.isDirectory()) { String name=entry.getName(); int lastSlashIndex = name.lastIndexOf('/'); String directoryName=""; String shortName=name; if (lastSlashIndex > -1) { directoryName=name.substring(0, lastSlashIndex); shortName=name.substring(lastSlashIndex+1); } getDirectory(directoryName).addEntry(zipFile,entry,shortName); } } return rootInfo; } private ZipDirInfo getDirectory(String dirName) { ZipDirInfo zipDir=(ZipDirInfo)directoryMap.get(dirName); if (zipDir==null){ ZipDirInfo parentInfo; int lastSlashIndex = dirName.lastIndexOf('/'); String shortName=dirName; if (lastSlashIndex > -1) { String parentDirName = dirName.substring(0, lastSlashIndex); shortName=dirName.substring(lastSlashIndex+1); parentInfo=getDirectory(parentDirName); } else { parentInfo=rootInfo; } zipDir=new ZipDirInfo(dirName,shortName); parentInfo.addDir(zipDir); directoryMap.put(dirName,zipDir); } return zipDir; } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.