29
29
import org .codehaus .plexus .components .io .attributes .PlexusIoResourceAttributes ;
30
30
import org .codehaus .plexus .components .io .resources .PlexusIoFileResource ;
31
31
import org .codehaus .plexus .components .io .resources .PlexusIoResource ;
32
+ import org .codehaus .plexus .components .io .resources .PlexusIoResourceCollection ;
32
33
import org .codehaus .plexus .components .io .resources .PlexusIoResourceWithAttributes ;
33
34
34
35
/**
@@ -43,6 +44,9 @@ public class ArchiveEntry
43
44
public static final int DIRECTORY = 2 ;
44
45
45
46
public static final int SYMLINK = 3 ;
47
+
48
+ private PlexusIoResourceCollection collection ;
49
+
46
50
@ Nonnull private PlexusIoResource resource ;
47
51
48
52
private final String name ;
@@ -59,11 +63,14 @@ public class ArchiveEntry
59
63
* @param resource original filename
60
64
* @param type FILE or DIRECTORY
61
65
* @param mode octal unix style permissions
66
+ * @param collection
62
67
*/
63
- private ArchiveEntry ( String name , @ Nonnull PlexusIoResource resource , int type , int mode )
68
+ private ArchiveEntry ( String name , @ Nonnull PlexusIoResource resource , int type , int mode ,
69
+ PlexusIoResourceCollection collection )
64
70
{
65
71
this .name = name ;
66
72
this .resource = resource ;
73
+ this .collection = collection ;
67
74
this .attributes = ( resource instanceof PlexusIoResourceWithAttributes )
68
75
? ( (PlexusIoResourceWithAttributes ) resource ).getAttributes () : null ;
69
76
this .type = type ;
@@ -108,7 +115,7 @@ public File getFile()
108
115
public InputStream getInputStream ()
109
116
throws IOException
110
117
{
111
- return resource .getContents ();
118
+ return collection != null ? collection . getInputStream ( resource ) : resource .getContents ();
112
119
}
113
120
114
121
/**
@@ -139,15 +146,16 @@ public int getMode()
139
146
( type == FILE ? UnixStat .FILE_FLAG : type == SYMLINK ? UnixStat .LINK_FLAG : UnixStat .DIR_FLAG );
140
147
}
141
148
142
- public static ArchiveEntry createFileEntry ( String target , PlexusIoResource resource , int permissions )
149
+ public static ArchiveEntry createFileEntry ( String target , PlexusIoResource resource , int permissions ,
150
+ PlexusIoResourceCollection collection )
143
151
throws ArchiverException
144
152
{
145
153
if ( resource .isDirectory () )
146
154
{
147
155
throw new ArchiverException ( "Not a file: " + resource .getName () );
148
156
}
149
157
final int type = resource .isSymbolicLink () ? SYMLINK : FILE ;
150
- return new ArchiveEntry ( target , resource , type , permissions );
158
+ return new ArchiveEntry ( target , resource , type , permissions , collection );
151
159
}
152
160
153
161
public static ArchiveEntry createFileEntry ( String target , File file , int permissions )
@@ -169,7 +177,7 @@ public static ArchiveEntry createFileEntry( String target, File file, int permis
169
177
}
170
178
171
179
final PlexusIoFileResource res = PlexusIoFileResource .justAFile ( file , attrs );
172
- return new ArchiveEntry ( target , res , FILE , permissions );
180
+ return new ArchiveEntry ( target , res , FILE , permissions , null );
173
181
}
174
182
175
183
public static ArchiveEntry createDirectoryEntry ( String target , @ Nonnull PlexusIoResource resource , int permissions )
@@ -180,7 +188,7 @@ public static ArchiveEntry createDirectoryEntry( String target, @Nonnull PlexusI
180
188
throw new ArchiverException ( "Not a directory: " + resource .getName () );
181
189
}
182
190
final int type = resource .isSymbolicLink () ? SYMLINK : DIRECTORY ;
183
- return new ArchiveEntry ( target , resource , type , permissions );
191
+ return new ArchiveEntry ( target , resource , type , permissions , null );
184
192
}
185
193
186
194
public static ArchiveEntry createDirectoryEntry ( String target , final File file , int permissions )
@@ -192,7 +200,7 @@ public static ArchiveEntry createDirectoryEntry( String target, final File file,
192
200
}
193
201
194
202
final PlexusIoFileResource res = new PlexusIoFileResource ( file , ArchiverAttributeUtils .getFileAttributes (file ));
195
- return new ArchiveEntry ( target , res , DIRECTORY , permissions );
203
+ return new ArchiveEntry ( target , res , DIRECTORY , permissions , null );
196
204
}
197
205
198
206
public static ArchiveEntry createEntry ( String target , File file , int filePerm , int dirPerm )
@@ -215,7 +223,8 @@ else if ( file.isFile() )
215
223
public static ArchiveEntry createSymlinkEntry (String symlinkName , int permissions , String symlinkDestination )
216
224
{
217
225
File symlinkFile = new File (symlinkName );
218
- final ArchiveEntry archiveEntry = new ArchiveEntry (symlinkName , new PlexusIoVirtualSymlinkResource (symlinkFile , symlinkDestination ), SYMLINK , permissions );
226
+ final ArchiveEntry archiveEntry = new ArchiveEntry (symlinkName , new PlexusIoVirtualSymlinkResource (symlinkFile , symlinkDestination ), SYMLINK , permissions ,
227
+ null );
219
228
return archiveEntry ;
220
229
}
221
230
0 commit comments