Ignore:
Timestamp:
2/3/2010 3:37:13 AM (2 years ago)
Author:
lowjoel
Message:

Forward ported changes from trunk to r1743

Location:
branches/eraser6/CodeReview
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/CodeReview

  • branches/eraser6/CodeReview/Eraser.DefaultPlugins/ErasureMethods/FirstLast16KB.cs

    r1681 r1745  
    113113                    "limited, since this is a self-limiting erasure method.")); 
    114114 
    115             //If the target stream is shorter than 16kb, just forward it to the default 
    116             //function. 
    117             if (strm.Length < dataSize) 
     115            //If the target stream is shorter than or equal to 32kb, just forward it to 
     116            //the default function. 
     117            if (strm.Length < dataSize * 2) 
    118118            { 
    119119                method.Erase(strm, erasureLength, prng, callback); 
     
    121121            } 
    122122 
     123            //We need to intercept the callback function as we run the erasure method 
     124            //twice on two parts of the file. 
     125            ErasureMethodProgressFunction customCallback = 
     126                delegate(long lastWritten, long totalData, int currentPass) 
     127                { 
     128                    callback(lastWritten, dataSize * 2, currentPass); 
     129                }; 
     130 
    123131            //Seek to the beginning and write 16kb. 
    124132            strm.Seek(0, SeekOrigin.Begin); 
    125             method.Erase(strm, dataSize, prng, callback); 
     133            method.Erase(strm, dataSize, prng, callback == null ? null: customCallback); 
    126134 
    127135            //Seek to the end - 16kb, and write. 
    128136            strm.Seek(-dataSize, SeekOrigin.End); 
    129             method.Erase(strm, long.MaxValue, prng, callback); 
     137            method.Erase(strm, long.MaxValue, prng, callback == null ? null : customCallback); 
    130138        } 
    131139 
Note: See TracChangeset for help on using the changeset viewer.