@@ -286,58 +286,6 @@ public bool ContinueRunning
286
286
public delegate void FileFailureHandler ( object sender , ScanFailureEventArgs e ) ;
287
287
#endregion
288
288
289
- /// <summary>
290
- /// An exception encountered dutring scanning.
291
- /// </summary>
292
- #if ! NETCF_1_0 && ! NETCF_2_0
293
- [ Serializable ]
294
- #endif
295
- public class ScanException : SharpZipBaseException
296
- {
297
- /// <summary>
298
- /// Initializes a new instance of the <see cref="ScanException"/> class.
299
- /// </summary>
300
- public ScanException ( )
301
- {
302
- }
303
-
304
- /// <summary>
305
- /// Initializes a new instance of the <see cref="ScanException"/> class.
306
- /// </summary>
307
- /// <param name="message">The message.</param>
308
- public ScanException ( string message )
309
- : base ( message )
310
- {
311
- }
312
-
313
- /// <summary>
314
- /// Initializes a new instance of the <see cref="ScanException"/> class.
315
- /// </summary>
316
- /// <param name="message">The message.</param>
317
- /// <param name="innerException">The inner exception.</param>
318
- public ScanException ( string message , Exception innerException )
319
- : base ( message , innerException )
320
- {
321
- }
322
-
323
- #if ! NETCF_1_0 && ! NETCF_2_0
324
- /// <summary>
325
- /// Initializes a new instance of the <see cref="ScanException"/> class.
326
- /// </summary>
327
- /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
328
- /// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination.</param>
329
- /// <exception cref="T:System.ArgumentNullException">The <paramref name="info"/> parameter is null. </exception>
330
- /// <exception cref="T:System.Runtime.Serialization.SerializationException">The class name is null or <see cref="P:System.Exception.HResult"/> is zero (0). </exception>
331
- public ScanException (
332
- System . Runtime . Serialization . SerializationInfo info ,
333
- System . Runtime . Serialization . StreamingContext context
334
- )
335
- : base ( info , context )
336
- {
337
- }
338
- #endif
339
- }
340
-
341
289
/// <summary>
342
290
/// FileSystemScanner provides facilities scanning of files and directories.
343
291
/// </summary>
@@ -417,36 +365,35 @@ public FileSystemScanner(IScanFilter fileFilter, IScanFilter directoryFilter)
417
365
/// </summary>
418
366
/// <param name="directory">The directory name.</param>
419
367
/// <param name="e">The exception detected.</param>
420
- void OnDirectoryFailure ( string directory , Exception e )
368
+ bool OnDirectoryFailure ( string directory , Exception e )
421
369
{
422
370
DirectoryFailureHandler handler = DirectoryFailure ;
423
- if ( handler == null ) {
424
- alive_ = false ;
425
- throw new ScanException ( "Directory scan failure" , e ) ;
426
- }
427
- else {
371
+ bool result = ( handler != null ) ;
372
+ if ( result ) {
428
373
ScanFailureEventArgs args = new ScanFailureEventArgs ( directory , e ) ;
429
374
handler ( this , args ) ;
430
375
alive_ = args . ContinueRunning ;
431
376
}
377
+ return result ;
432
378
}
433
379
434
380
/// <summary>
435
381
/// Raise the FileFailure event.
436
382
/// </summary>
437
383
/// <param name="file">The file name.</param>
438
384
/// <param name="e">The exception detected.</param>
439
- void OnFileFailure ( string file , Exception e )
385
+ bool OnFileFailure ( string file , Exception e )
440
386
{
441
387
FileFailureHandler handler = FileFailure ;
442
- if ( handler == null ) {
443
- alive_ = false ;
444
- throw new ScanException ( "File failure" , e ) ;
445
- } else {
388
+
389
+ bool result = ( handler != null ) ;
390
+
391
+ if ( result ) {
446
392
ScanFailureEventArgs args = new ScanFailureEventArgs ( file , e ) ;
447
393
FileFailure ( this , args ) ;
448
394
alive_ = args . ContinueRunning ;
449
395
}
396
+ return result ;
450
397
}
451
398
452
399
/// <summary>
@@ -534,13 +481,17 @@ void ScanDir(string directory, bool recurse)
534
481
}
535
482
}
536
483
catch ( Exception e ) {
537
- OnFileFailure ( fileName , e ) ;
484
+ if ( ! OnFileFailure ( fileName , e ) ) {
485
+ throw ;
486
+ }
538
487
}
539
488
}
540
489
}
541
490
}
542
491
catch ( Exception e ) {
543
- OnDirectoryFailure ( directory , e ) ;
492
+ if ( ! OnDirectoryFailure ( directory , e ) ) {
493
+ throw ;
494
+ }
544
495
}
545
496
546
497
if ( alive_ && recurse ) {
@@ -556,7 +507,9 @@ void ScanDir(string directory, bool recurse)
556
507
}
557
508
}
558
509
catch ( Exception e ) {
559
- OnDirectoryFailure ( directory , e ) ;
510
+ if ( ! OnDirectoryFailure ( directory , e ) ) {
511
+ throw ;
512
+ }
560
513
}
561
514
}
562
515
}
0 commit comments