*/
protected static final void grabFilesAndDirs( String file, List dirs,
List files )
throws IOException
{
ZipFile zf = null;
try
{
zf = new ZipFile( file, "utf-8" );
Enumeration entries = zf.getEntries();
HashSet dirSet = new HashSet();
while ( entries.hasMoreElements() )
{
ZipEntry ze =
(ZipEntry) entries.nextElement();
String name = ze.getName();
// avoid index for manifest-only jars.
if (!name.equals(META_INF_NAME) && !name.equals(META_INF_NAME+"/") &&
!name.equals(INDEX_NAME) && !name.equals(MANIFEST_NAME))
{
if ( ze.isDirectory() )
{
dirSet.add( name );
}
else if ( name.indexOf( "/" ) == -1 )
{
files.add( name );
}
else
{
// a file, not in the root
// since the jar may be one without directory
// entries, add the parent dir of this file as
// well.
dirSet.add( name.substring( 0,
name.lastIndexOf( "/" ) + 1 ) );
}
}
}
dirs.addAll( dirSet );
}
finally
{
if ( zf != null )
{
zf.close();
}
}
}