20
20
import java .io .File ;
21
21
import java .io .IOException ;
22
22
import java .io .InputStream ;
23
+ import java .io .UnsupportedEncodingException ;
23
24
import java .net .URL ;
24
25
import java .util .Date ;
25
26
import java .util .Enumeration ;
27
+ import javax .annotation .Nonnull ;
26
28
29
+ import org .apache .commons .compress .archivers .zip .UnicodePathExtraField ;
27
30
import org .apache .commons .compress .archivers .zip .ZipArchiveEntry ;
28
31
import org .apache .commons .compress .archivers .zip .ZipFile ;
29
32
import org .apache .commons .compress .utils .IOUtils ;
33
+
30
34
import org .codehaus .plexus .archiver .AbstractUnArchiver ;
31
35
import org .codehaus .plexus .archiver .ArchiverException ;
32
36
import org .codehaus .plexus .components .io .resources .PlexusIoResource ;
33
37
34
- import javax .annotation .Nonnull ;
35
-
36
38
/**
37
39
* @author <a href="mailto:[email protected] ">Emmanuel Venisse</a>
38
40
* @version $Id$
@@ -84,7 +86,20 @@ private static class ZipEntryFileInfo
84
86
85
87
public String getName ()
86
88
{
87
- return zipEntry .getName ();
89
+ try
90
+ {
91
+ final UnicodePathExtraField unicodePath =
92
+ (UnicodePathExtraField ) zipEntry .getExtraField ( UnicodePathExtraField .UPATH_ID );
93
+
94
+ return unicodePath != null
95
+ ? new String ( unicodePath .getUnicodeName (), "UTF-8" )
96
+ : zipEntry .getName ();
97
+
98
+ }
99
+ catch ( final UnsupportedEncodingException e )
100
+ {
101
+ throw new AssertionError ( e );
102
+ }
88
103
}
89
104
90
105
public boolean isDirectory ()
@@ -141,27 +156,30 @@ protected void execute()
141
156
InputStream in = null ;
142
157
try
143
158
{
144
- zf = new org .apache .commons .compress .archivers .zip .ZipFile ( getSourceFile (), encoding );
145
- final Enumeration e = zf .getEntries ();
159
+ zf = new org .apache .commons .compress .archivers .zip .ZipFile ( getSourceFile (), encoding , true );
160
+ final Enumeration e = zf .getEntriesInPhysicalOrder ();
146
161
while ( e .hasMoreElements () )
147
162
{
148
163
final ZipArchiveEntry ze = (ZipArchiveEntry ) e .nextElement ();
149
164
final ZipEntryFileInfo fileInfo = new ZipEntryFileInfo ( zf , ze );
150
- if ( isSelected ( ze .getName (), fileInfo ) )
165
+ if ( isSelected ( fileInfo .getName (), fileInfo ) )
151
166
{
152
- in = zf .getInputStream ( ze );
153
- extractFileIfIncluded (getSourceFile (), getDestDirectory (), in , ze .getName (),
154
- new Date (ze .getTime ()), ze .isDirectory (), ze .getUnixMode () != 0 ? ze .getUnixMode () : null ,
155
- resolveSymlink ( zf , ze ) );
167
+ in = zf .getInputStream ( ze );
168
+
169
+ extractFileIfIncluded ( getSourceFile (), getDestDirectory (), in , fileInfo .getName (),
170
+ new Date ( ze .getTime () ), ze .isDirectory (),
171
+ ze .getUnixMode () != 0 ? ze .getUnixMode () : null ,
172
+ resolveSymlink ( zf , ze ) );
173
+
156
174
in .close ();
157
175
in = null ;
158
- }
159
-
160
- }
176
+ }
177
+ }
161
178
162
- getLogger ().debug ( "expand complete" );
163
179
zf .close ();
164
180
zf = null ;
181
+
182
+ getLogger ().debug ( "expand complete" );
165
183
}
166
184
catch ( final IOException ioe )
167
185
{
@@ -197,9 +215,9 @@ protected void execute( final String path, final File outputDirectory )
197
215
InputStream in = null ;
198
216
try
199
217
{
200
- zipFile = new org .apache .commons .compress .archivers .zip .ZipFile ( getSourceFile (), encoding );
218
+ zipFile = new org .apache .commons .compress .archivers .zip .ZipFile ( getSourceFile (), encoding , true );
201
219
202
- final Enumeration e = zipFile .getEntries ();
220
+ final Enumeration e = zipFile .getEntriesInPhysicalOrder ();
203
221
204
222
while ( e .hasMoreElements () )
205
223
{
@@ -213,9 +231,12 @@ protected void execute( final String path, final File outputDirectory )
213
231
if ( ze .getName ().startsWith ( path ) )
214
232
{
215
233
in = zipFile .getInputStream ( ze );
234
+
216
235
extractFileIfIncluded ( getSourceFile (), outputDirectory , in ,
217
236
ze .getName (), new Date ( ze .getTime () ), ze .isDirectory (),
218
- ze .getUnixMode () != 0 ? ze .getUnixMode () : null , resolveSymlink ( zipFile , ze ) );
237
+ ze .getUnixMode () != 0 ? ze .getUnixMode () : null ,
238
+ resolveSymlink ( zipFile , ze ) );
239
+
219
240
in .close ();
220
241
in = null ;
221
242
}
0 commit comments