@@ -93,11 +93,17 @@ void ListDir(object Sender, DirectoryEventArgs e)
93
93
void ListFileSystem ( string directory , bool recurse , string fileFilter , string directoryFilter )
94
94
{
95
95
FileSystemScanner scanner = new FileSystemScanner ( fileFilter , directoryFilter ) ;
96
- scanner . ProcessDirectory += new ProcessDirectoryDelegate ( ListDir ) ;
97
- scanner . ProcessFile += new ProcessFileDelegate ( ListFile ) ;
96
+ scanner . ProcessDirectory += new ProcessDirectoryHandler ( ListDir ) ;
97
+ scanner . ProcessFile += new ProcessFileHandler ( ListFile ) ;
98
98
scanner . Scan ( directory , recurse ) ;
99
99
}
100
-
100
+
101
+ void ShowProgress ( object sender , ProgressEventArgs e )
102
+ {
103
+ // Very ugly but this is a sample!
104
+ Console . WriteLine ( "{0}%" , e . PercentComplete ) ;
105
+ }
106
+
101
107
void ProcessFile ( object sender , ScanEventArgs e )
102
108
{
103
109
Console . WriteLine ( e . Name ) ;
@@ -127,6 +133,8 @@ void Run(string[] args)
127
133
bool verbose = false ;
128
134
bool restoreDates = false ;
129
135
bool restoreAttributes = false ;
136
+ bool progress = false ;
137
+ TimeSpan interval = TimeSpan . FromSeconds ( 1 ) ;
130
138
131
139
bool createEmptyDirs = false ;
132
140
FastZip . Overwrite overwrite = FastZip . Overwrite . Always ;
@@ -190,6 +198,12 @@ void Run(string[] args)
190
198
break ;
191
199
192
200
201
+ case "p" :
202
+ case "progress" :
203
+ progress = true ;
204
+ verbose = true ;
205
+ break ;
206
+
193
207
case "r" :
194
208
case "recurse" :
195
209
recurse = true ;
@@ -199,7 +213,13 @@ void Run(string[] args)
199
213
case "verbose" :
200
214
verbose = true ;
201
215
break ;
202
-
216
+
217
+ case "i" :
218
+ if ( optArg . Length > 0 ) {
219
+ interval = TimeSpan . FromSeconds ( int . Parse ( optArg ) ) ;
220
+ }
221
+ break ;
222
+
203
223
case "file" :
204
224
if ( NameFilter . IsValidFilterExpression ( optArg ) ) {
205
225
fileFilter = optArg ;
@@ -274,21 +294,27 @@ void Run(string[] args)
274
294
275
295
if ( verbose ) {
276
296
events = new FastZipEvents ( ) ;
277
- events . ProcessDirectory = new ProcessDirectoryDelegate ( ProcessDirectory ) ;
278
- events . ProcessFile = new ProcessFileDelegate ( ProcessFile ) ;
297
+ events . ProcessDirectory = new ProcessDirectoryHandler ( ProcessDirectory ) ;
298
+ events . ProcessFile = new ProcessFileHandler ( ProcessFile ) ;
299
+
300
+ if ( progress )
301
+ {
302
+ events . Progress = new ProgressHandler ( ShowProgress ) ;
303
+ events . ProgressInterval = interval ;
304
+ }
279
305
}
280
306
281
- FastZip sz = new FastZip ( events ) ;
282
- sz . CreateEmptyDirectories = createEmptyDirs ;
283
- sz . RestoreAttributesOnExtract = restoreAttributes ;
284
- sz . RestoreDateTimeOnExtract = restoreDates ;
307
+ FastZip fastZip = new FastZip ( events ) ;
308
+ fastZip . CreateEmptyDirectories = createEmptyDirs ;
309
+ fastZip . RestoreAttributesOnExtract = restoreAttributes ;
310
+ fastZip . RestoreDateTimeOnExtract = restoreDates ;
285
311
286
312
switch ( op ) {
287
313
case Operation . Create :
288
314
if ( argCount == 2 ) {
289
315
Console . WriteLine ( "Creating Zip" ) ;
290
316
291
- sz . CreateZip ( arg1 , arg2 , recurse , fileFilter , dirFilter ) ;
317
+ fastZip . CreateZip ( arg1 , arg2 , recurse , fileFilter , dirFilter ) ;
292
318
}
293
319
else
294
320
Console . WriteLine ( "Invalid arguments" ) ;
@@ -297,7 +323,7 @@ void Run(string[] args)
297
323
case Operation . Extract :
298
324
if ( argCount == 2 ) {
299
325
Console . WriteLine ( "Extracting Zip" ) ;
300
- sz . ExtractZip ( arg1 , arg2 , overwrite , confirmOverwrite , fileFilter , dirFilter , recurse ) ;
326
+ fastZip . ExtractZip ( arg1 , arg2 , overwrite , confirmOverwrite , fileFilter , dirFilter , recurse ) ;
301
327
}
302
328
else
303
329
Console . WriteLine ( "zipfile and target directory not specified" ) ;
@@ -317,17 +343,19 @@ void Run(string[] args)
317
343
318
344
case Operation . Unknown :
319
345
Console . WriteLine (
320
- "FastZip v0.4 \n "
346
+ "FastZip v0.5 \n "
321
347
+ " Usage: FastZip {options} operation args\n "
322
348
+ "Operation Options: (only one permitted)\n "
323
349
+ " -x zipfile targetdir : Extract files from Zip\n "
324
350
+ " -c zipfile sourcedir : Create zip file\n "
325
351
+ " -l zipfile|dir : List elements\n "
326
352
+ "\n "
327
353
+ "Behavioural options:\n "
328
- + " -file={fileFilter}\n "
329
354
+ " -dir={dirFilter}\n "
355
+ + " -file={fileFilter}\n "
330
356
+ " -e Process empty directories\n "
357
+ + " -i Progress interval in seconds\n "
358
+ + " -p Show file progress\n "
331
359
+ " -r Recurse directories\n "
332
360
+ " -v Verbose output\n "
333
361
+ " -oa Restore file attributes on extract\n "
0 commit comments