7
7
//
8
8
//------------------------------------------------------------------------------
9
9
// Version History
10
- // 0.1 Initial version ported from sz sample. Some stuff is not used or commented still
11
- // 0.2 Display files during extract. --env Now shows .NET version information.
10
+ // 1 Initial version ported from sz sample. Some stuff is not used or commented still
11
+ // 2 Display files during extract. --env Now shows .NET version information.
12
+ // 3 Add usezip64 option as a testing aid.
12
13
13
14
14
15
using System ;
@@ -102,7 +103,7 @@ bool SetArgs(string[] args)
102
103
103
104
#if OPTIONTEST
104
105
Console . WriteLine ( "args index [{0}] option [{1}] argument [{2}]" , argIndex , option , optArg ) ;
105
- #endif
106
+ #endif
106
107
if ( option . Length == 0 )
107
108
{
108
109
System . Console . Error . WriteLine ( "Invalid argument (0}" , args [ argIndex ] ) ;
@@ -115,7 +116,7 @@ bool SetArgs(string[] args)
115
116
{
116
117
#if OPTIONTEST
117
118
Console . WriteLine ( "optionIndex {0}" , optionIndex ) ;
118
- #endif
119
+ #endif
119
120
switch ( option [ optionIndex ] )
120
121
{
121
122
case '-' : // long option
@@ -163,6 +164,26 @@ bool SetArgs(string[] args)
163
164
testData_ = true ;
164
165
break ;
165
166
167
+ case "-zip64" :
168
+ if ( optArg . Length > 0 )
169
+ {
170
+ switch ( optArg )
171
+ {
172
+ case "on" :
173
+ useZip64_ = UseZip64 . On ;
174
+ break ;
175
+
176
+ case "off" :
177
+ useZip64_ = UseZip64 . Off ;
178
+ break ;
179
+
180
+ case "auto" :
181
+ useZip64_ = UseZip64 . Dynamic ;
182
+ break ;
183
+ }
184
+ }
185
+ break ;
186
+
166
187
case "-encoding" :
167
188
if ( optArg . Length > 0 )
168
189
{
@@ -175,7 +196,7 @@ bool SetArgs(string[] args)
175
196
{
176
197
#if OPTIONTEST
177
198
Console . WriteLine ( "Encoding set to {0}" , enc ) ;
178
- #endif
199
+ #endif
179
200
ZipConstants . DefaultCodePage = enc ;
180
201
}
181
202
else
@@ -340,7 +361,7 @@ bool SetArgs(string[] args)
340
361
{
341
362
#if OPTIONTEST
342
363
Console . WriteLine ( "file spec {0} = '{1}'" , argIndex , args [ argIndex ] ) ;
343
- #endif
364
+ #endif
344
365
fileSpecs_ . Add ( args [ argIndex ] ) ;
345
366
}
346
367
++ argIndex ;
@@ -350,7 +371,7 @@ bool SetArgs(string[] args)
350
371
{
351
372
string checkPath = ( string ) fileSpecs_ [ 0 ] ;
352
373
int deviceCheck = checkPath . IndexOf ( ':' ) ;
353
- #if NET_VER_1
374
+ #if NET_VER_1
354
375
if ( checkPath . IndexOfAny ( Path . InvalidPathChars ) >= 0
355
376
#else
356
377
if ( checkPath . IndexOfAny ( Path . GetInvalidPathChars ( ) ) >= 0
@@ -396,7 +417,7 @@ void ShowEnvironment()
396
417
void ShowVersion ( )
397
418
{
398
419
seenHelp_ = true ;
399
- Console . Out . WriteLine ( "ZipFile Archiver v0.2 Copyright 2006 John Reilly" ) ;
420
+ Console . Out . WriteLine ( "ZipFile Archiver v0.3 Copyright 2006 John Reilly" ) ;
400
421
401
422
Assembly [ ] assemblies = AppDomain . CurrentDomain . GetAssemblies ( ) ;
402
423
@@ -440,6 +461,7 @@ void ShowHelp()
440
461
Console . Out . WriteLine ( "--version Show version information" ) ;
441
462
Console . Out . WriteLine ( "-r Recurse sub-folders" ) ;
442
463
Console . Out . WriteLine ( "-s=password Set archive password" ) ;
464
+ Console . Out . WriteLine ( "--zip64=[on|off|auto] Zip64 extension handling to use" ) ;
443
465
444
466
445
467
/*
@@ -621,6 +643,8 @@ void Create(ArrayList fileSpecs)
621
643
using ( ZipFile zf = ZipFile . Create ( zipFileName ) )
622
644
{
623
645
zf . Password = password_ ;
646
+ zf . UseZip64 = useZip64_ ;
647
+
624
648
zf . BeginUpdate ( ) ;
625
649
626
650
activeZipFile_ = zf ;
@@ -678,7 +702,7 @@ bool ExtractFile(Stream inputStream, ZipEntry theEntry, string targetDir)
678
702
#if TEST
679
703
Console . WriteLine ( "Decompress targetfile name " + entryFileName ) ;
680
704
Console . WriteLine ( "Decompress targetpath " + fullPath ) ;
681
- #endif
705
+ #endif
682
706
683
707
// Could be an option or parameter to allow failure or try creation
684
708
if ( Directory . Exists ( fullPath ) == false )
@@ -1009,6 +1033,8 @@ void Add(ArrayList fileSpecs)
1009
1033
using ( zipFile )
1010
1034
{
1011
1035
zipFile . Password = password_ ;
1036
+ zipFile . UseZip64 = useZip64_ ;
1037
+
1012
1038
zipFile . BeginUpdate ( ) ;
1013
1039
1014
1040
activeZipFile_ = zipFile ;
@@ -1390,6 +1416,11 @@ public static void Main(string[] args)
1390
1416
/// The size of buffer to provide. <see cref="GetBuffer"></see>
1391
1417
/// </summary>
1392
1418
int bufferSize_ = 4096 ;
1419
+
1420
+ /// <summary>
1421
+ /// The Zip64 extension use to apply.
1422
+ /// </summary>
1423
+ UseZip64 useZip64_ = UseZip64 . Off ;
1393
1424
#endregion
1394
1425
}
1395
1426
}
0 commit comments