@@ -200,16 +200,33 @@ public bool IsUnicodeText
200
200
set { isUnicodeText_ = value ; }
201
201
}
202
202
203
- #endregion
203
+ #endregion
204
204
205
- #region IEntryFactory Members
205
+ #region Private Methods
206
206
207
- /// <summary>
208
- /// Make a new <see cref="ZipEntry"/> for a file.
209
- /// </summary>
210
- /// <param name="fileName">The name of the file to create a new entry for.</param>
211
- /// <returns>Returns a new <see cref="ZipEntry"/> based on the <paramref name="fileName"/>.</returns>
212
- public ZipEntry MakeFileEntry ( string fileName )
207
+ /// <summary>
208
+ /// Check whether the file name is unicode encoded or not.
209
+ /// </summary>
210
+ /// <param name="fileName">The name of the file to check its encoding.</param>
211
+ /// <returns></returns>
212
+ private bool IsUnicodeFileName ( string fileName )
213
+ {
214
+ Encoding defaultEncoding = Encoding . GetEncoding ( ZipConstants . DefaultCodePage ) ;
215
+ byte [ ] unicodeFileNameBytes = defaultEncoding . GetBytes ( fileName ) ;
216
+ string unicodeFileName = defaultEncoding . GetString ( unicodeFileNameBytes ) ;
217
+ return unicodeFileName != fileName ;
218
+ }
219
+
220
+ #endregion
221
+
222
+ #region IEntryFactory Members
223
+
224
+ /// <summary>
225
+ /// Make a new <see cref="ZipEntry"/> for a file.
226
+ /// </summary>
227
+ /// <param name="fileName">The name of the file to create a new entry for.</param>
228
+ /// <returns>Returns a new <see cref="ZipEntry"/> based on the <paramref name="fileName"/>.</returns>
229
+ public ZipEntry MakeFileEntry ( string fileName )
213
230
{
214
231
return MakeFileEntry ( fileName , null , true ) ;
215
232
}
@@ -236,15 +253,11 @@ public ZipEntry MakeFileEntry(string fileName, string entryName, bool useFileSys
236
253
ZipEntry result = new ZipEntry ( nameTransform_ . TransformFile ( entryName != null && entryName . Length > 0 ? entryName : fileName ) ) ;
237
254
result . IsUnicodeText = isUnicodeText_ ;
238
255
239
- Encoding defaultEncoding = Encoding . GetEncoding ( ZipConstants . DefaultCodePage ) ;
240
- byte [ ] unicodeFileNameBytes = defaultEncoding . GetBytes ( result . Name ) ;
241
- string unicodeFileName = defaultEncoding . GetString ( unicodeFileNameBytes ) ;
242
- if ( unicodeFileName != result . Name )
256
+ if ( IsUnicodeFileName ( result . Name ) )
243
257
{
244
258
result . IsUnicodeText = true ;
245
259
}
246
260
247
-
248
261
int externalAttributes = 0 ;
249
262
bool useAttributes = ( setAttributes_ != 0 ) ;
250
263
0 commit comments