Skip to content

Commit 32af216

Browse files
committed
PLXCOMP-153, PLXCOMP-205. Adding support for includes/excludes to TarUnArchiver
1 parent 6d5f744 commit 32af216

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/main/java/org/codehaus/plexus/archiver/tar/TarUnArchiver.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,23 @@ protected void execute()
8383
try
8484
{
8585
getLogger().info( "Expanding: " + getSourceFile() + " into " + getDestDirectory() );
86-
tis = new TarInputStream( compression.decompress( getSourceFile(),
86+
File sourceFile = getSourceFile();
87+
TarFile tarFile = new TarFile( sourceFile );
88+
tis = new TarInputStream( compression.decompress( sourceFile,
8789
new BufferedInputStream(
88-
new FileInputStream( getSourceFile() ) ) ) );
90+
new FileInputStream( sourceFile ) ) ) );
8991
TarEntry te;
9092

9193
while ( ( te = tis.getNextEntry() ) != null )
9294
{
93-
extractFile( getSourceFile(), getDestDirectory(), tis, te.getName(), te.getModTime(),
94-
te.isDirectory(), te.getMode() != 0 ? te.getMode() : null);
95+
96+
TarResource fileInfo = new TarResource( tarFile, te);
97+
if (!isSelected( te.getName(), fileInfo )) {
98+
continue;
99+
}
100+
101+
extractFile(getSourceFile(), getDestDirectory(), tis, te.getName(), te.getModTime(),
102+
te.isDirectory(), te.getMode() != 0 ? te.getMode() : null);
95103
}
96104
getLogger().debug( "expand complete" );
97105

0 commit comments

Comments
 (0)