Changeset 1880

Show
Ignore:
Timestamp:
3/5/2010 12:48:08 AM (5 months ago)
Author:
lowjoel
Message:

Fixed cluster tip failures reported by DavidHB.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/eraser6/Eraser.DefaultPlugins/FileSystems/Windows.cs

    r1870 r1880  
    343343            //Otherwise, create the stream, lengthen the file, then tell the erasure 
    344344            //method to erase the cluster tips. 
    345             using (FileStream stream = streamInfo.Open(FileMode.Open, FileAccess.Write, 
    346                 FileShare.None, FileOptions.WriteThrough)) 
    347             { 
    348                 try 
    349                 { 
    350                     stream.SetLength(fileArea); 
    351                     stream.Seek(fileLength, SeekOrigin.Begin); 
    352  
    353                     //Erase the file 
    354                     method.Erase(stream, long.MaxValue, 
    355                         ManagerLibrary.Instance.PrngRegistrar[ManagerLibrary.Settings.ActivePrng], 
    356                         null); 
    357                 } 
    358                 finally 
    359                 { 
    360                     //Make sure the file length is restored! 
    361                     stream.SetLength(fileLength); 
    362  
    363                     //Reset the file times 
    364                     streamInfo.LastAccessTime = lastAccess; 
    365                     streamInfo.LastWriteTime = lastWrite; 
    366                     streamInfo.CreationTime = created; 
    367                 } 
     345            try 
     346            { 
     347                using (FileStream stream = streamInfo.Open(FileMode.Open, FileAccess.Write, 
     348                    FileShare.None, FileOptions.WriteThrough)) 
     349                { 
     350                    try 
     351                    { 
     352                        stream.SetLength(fileArea); 
     353                        stream.Seek(fileLength, SeekOrigin.Begin); 
     354 
     355                        //Erase the file 
     356                        method.Erase(stream, long.MaxValue, 
     357                            ManagerLibrary.Instance.PrngRegistrar[ 
     358                                ManagerLibrary.Settings.ActivePrng], 
     359                            null); 
     360                    } 
     361                    finally 
     362                    { 
     363                        //Make sure the file length is restored! 
     364                        stream.SetLength(fileLength); 
     365                    } 
     366                } 
     367            } 
     368            finally 
     369            { 
     370                //Reset the file times 
     371                streamInfo.LastAccessTime = lastAccess; 
     372                streamInfo.LastWriteTime = lastWrite; 
     373                streamInfo.CreationTime = created; 
    368374            } 
    369375        }