-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathPlexusIoTarFileResourceCollection.java
68 lines (57 loc) · 1.86 KB
/
PlexusIoTarFileResourceCollection.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package org.codehaus.plexus.archiver.tar;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Iterator;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.codehaus.plexus.components.io.resources.AbstractPlexusIoArchiveResourceCollection;
import org.codehaus.plexus.components.io.resources.PlexusIoResource;
public class PlexusIoTarFileResourceCollection
extends AbstractPlexusIoArchiveResourceCollection implements Closeable
{
/**
* The zip file resource collections role hint.
*/
public static final String ROLE_HINT = "tar";
protected TarFile newTarFile( File file )
{
return new TarFile( file );
}
TarFile tarFile = null;
public void close()
throws IOException
{
if (tarFile != null) tarFile.close();
}
protected Iterator<PlexusIoResource> getEntries()
throws IOException
{
final File f = getFile();
if ( f == null )
{
throw new IOException( "The tar archive file has not been set." );
}
if (tarFile == null)
tarFile = newTarFile( f );
final Enumeration en = tarFile.getEntries();
return new Iterator<PlexusIoResource>()
{
public boolean hasNext()
{
return en.hasMoreElements();
}
public PlexusIoResource next()
{
final TarArchiveEntry entry = (TarArchiveEntry) en.nextElement();
return !entry.isSymbolicLink()
? new TarResource( tarFile, entry )
: new TarSymlinkResource( tarFile, entry );
}
public void remove()
{
throw new UnsupportedOperationException( "Removing isn't implemented." );
}
};
}
}