@@ -79,16 +79,11 @@ public abstract class AbstractZipArchiver
79
79
80
80
protected String archiveType = "zip" ;
81
81
82
- /*
83
- * Whether the original compression of entries coming from a ZIP
84
- * archive should be kept (for example when updating an archive).
85
- */
86
- //not used: private boolean keepCompression = false;
87
82
private boolean doFilesonly = false ;
88
83
89
84
protected final Hashtable <String , String > entries = new Hashtable <String , String >();
90
85
91
- protected final Hashtable < String , String > addedDirs = new Hashtable < String , String > ();
86
+ protected final AddedDirs addedDirs = new AddedDirs ();
92
87
93
88
private static final long EMPTY_CRC = new CRC32 ().getValue ();
94
89
@@ -363,7 +358,7 @@ protected final void addResources( ResourceIterator resources, ParallelScatterZi
363
358
name = name + "/" ;
364
359
}
365
360
366
- addParentDirs ( entry , null , name , zOut , "" );
361
+ addParentDirs ( entry , null , name , zOut );
367
362
368
363
if ( entry .getResource ().isFile () )
369
364
{
@@ -384,29 +379,12 @@ protected final void addResources( ResourceIterator resources, ParallelScatterZi
384
379
* be impossible and is not really supported.
385
380
*/
386
381
@ SuppressWarnings ( { "JavaDoc" } )
387
- private void addParentDirs ( ArchiveEntry archiveEntry , File baseDir , String entry , ParallelScatterZipCreator zOut ,
388
- String prefix )
382
+ private void addParentDirs (ArchiveEntry archiveEntry , File baseDir , String entry , ParallelScatterZipCreator zOut )
389
383
throws IOException
390
384
{
391
385
if ( !doFilesonly && getIncludeEmptyDirs () )
392
386
{
393
- Stack <String > directories = new Stack <String >();
394
-
395
- // Don't include the last entry itself if it's
396
- // a dir; it will be added on its own.
397
- int slashPos = entry .length () - ( entry .endsWith ( "/" ) ? 1 : 0 );
398
-
399
- while ( ( slashPos = entry .lastIndexOf ( '/' , slashPos - 1 ) ) != -1 )
400
- {
401
- String dir = entry .substring ( 0 , slashPos + 1 );
402
-
403
- if ( addedDirs .contains ( prefix + dir ) )
404
- {
405
- break ;
406
- }
407
-
408
- directories .push ( dir );
409
- }
387
+ Stack <String > directories = addedDirs .asStringStack (entry );
410
388
411
389
while ( !directories .isEmpty () )
412
390
{
@@ -423,12 +401,12 @@ private void addParentDirs( ArchiveEntry archiveEntry, File baseDir, String entr
423
401
// the
424
402
// At this point we could do something like read the atr
425
403
final PlexusIoResource res = new AnonymousResource ( f );
426
- zipDir ( res , zOut , prefix + dir , archiveEntry .getDefaultDirMode (), encoding );
404
+ zipDir ( res , zOut , dir , archiveEntry .getDefaultDirMode (), encoding );
427
405
}
428
406
}
429
407
}
430
408
431
- /**
409
+ /**
432
410
* Adds a new entry to the archive, takes care of duplicates as well.
433
411
*
434
412
* @param in the stream to read data for the entry from.
@@ -544,15 +522,12 @@ protected void zipDir( PlexusIoResource dir, ParallelScatterZipCreator zOut, Str
544
522
String encodingToUse )
545
523
throws IOException
546
524
{
547
- if ( addedDirs .get ( vPath ) != null )
525
+ if ( addedDirs .update ( vPath ) )
548
526
{
549
- // don't add directories we've already added.
550
- // no warning if we try, it is harmless in and of itself
551
527
return ;
552
528
}
553
529
554
- getLogger ().debug ( "adding directory " + vPath );
555
- addedDirs .put ( vPath , vPath );
530
+ getLogger ().debug ("adding directory " + vPath );
556
531
557
532
if ( !skipWriting )
558
533
{
0 commit comments