Skip to content

Commit

Permalink
Remove code duplication.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Patrikeev authored and plamentotev committed Aug 23, 2019
1 parent 4978d77 commit 2aec2ba
Showing 1 changed file with 3 additions and 25 deletions.
Expand Up @@ -158,31 +158,7 @@ public boolean isExisting()
protected void execute()
throws ArchiverException
{
getLogger().debug( "Expanding: " + getSourceFile() + " into " + getDestDirectory() );
try ( ZipFile zf = new ZipFile( getSourceFile(), encoding, true ) )
{
final Enumeration<ZipArchiveEntry> e = zf.getEntriesInPhysicalOrder();
while ( e.hasMoreElements() )
{
final ZipArchiveEntry ze = e.nextElement();
final ZipEntryFileInfo fileInfo = new ZipEntryFileInfo( zf, ze );
if ( isSelected( fileInfo.getName(), fileInfo ) )
{
try ( InputStream in = zf.getInputStream( ze ) )
{
extractFile( getSourceFile(), getDestDirectory(), in, fileInfo.getName(),
new Date( ze.getTime() ), ze.isDirectory(),
ze.getUnixMode() != 0 ? ze.getUnixMode() : null,
resolveSymlink( zf, ze ), getFileMappers() );
}
}
}
getLogger().debug( "expand complete" );
}
catch ( final IOException ioe )
{
throw new ArchiverException( "Error while expanding " + getSourceFile().getAbsolutePath(), ioe );
}
execute( "", getDestDirectory() );
}

private String resolveSymlink( ZipFile zf, ZipArchiveEntry ze )
Expand All @@ -202,6 +178,7 @@ private String resolveSymlink( ZipFile zf, ZipArchiveEntry ze )
protected void execute( final String path, final File outputDirectory )
throws ArchiverException
{
getLogger().debug( "Expanding: " + getSourceFile() + " into " + outputDirectory );
try ( ZipFile zipFile = new ZipFile( getSourceFile(), encoding, true ) )
{
final Enumeration<ZipArchiveEntry> e = zipFile.getEntriesInPhysicalOrder();
Expand All @@ -226,6 +203,7 @@ protected void execute( final String path, final File outputDirectory )
}
}
}
getLogger().debug( "expand complete" );
}
catch ( final IOException ioe )
{
Expand Down

0 comments on commit 2aec2ba

Please sign in to comment.