Changeset 262 for branches/eraser6/DefaultPlugins/EraseFirstLast16KB.cs
- Timestamp:
- 3/12/2008 7:19:44 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/DefaultPlugins/EraseFirstLast16KB.cs
r254 r262 27 27 public override long CalculateEraseDataSize(List<string> paths, long targetSize) 28 28 { 29 //Simple. Number of files multiplied by 32kb. 30 return paths.Count * dataSize * 2; 29 //Amount of data required to be written. 30 long amountToWrite = 0; 31 if (paths == null) 32 { 33 if (targetSize <= dataSize) 34 amountToWrite = targetSize; 35 else 36 amountToWrite = dataSize * 2; 37 } 38 else 39 amountToWrite = paths.Count * dataSize * 2; 40 41 //The final amount has to be multiplied by the number of passes. 42 return amountToWrite * Method.Passes; 31 43 } 32 44 … … 41 53 "limited, since this is a self-limiting erasure method."); 42 54 43 //Try to retrieve the default erasure method. 44 ErasureMethod defaultMethod = ErasureMethodManager.GetInstance( 45 Globals.Settings.DefaultFileErasureMethod); 46 47 //If we are the default, use the default pseudorandom pass. 48 if (defaultMethod.GUID == GUID) 49 defaultMethod = ErasureMethodManager.GetInstance(new Guid( 50 "{BF8BA267-231A-4085-9BF9-204DE65A6641}")); 55 ErasureMethod method = Method; 51 56 52 57 //If the target stream is shorter than 16kb, just forward it to the default … … 54 59 if (strm.Length < dataSize) 55 60 { 56 defaultMethod.Erase(strm, erasureLength, prng, callback);61 method.Erase(strm, erasureLength, prng, callback); 57 62 return; 58 63 } 59 64 60 //Declare our local anonymous function to forward the progress event61 //to the callback function.62 float baseCompleted = 0;63 OnProgress chainCallbackHandler = delegate(float currentProgress, int currentPass)64 {65 callback(baseCompleted + currentProgress / 2,66 (int)((baseCompleted * defaultMethod.Passes) + currentPass / 2));67 };68 69 65 //Seek to the beginning and write 16kb. 70 66 strm.Seek(0, SeekOrigin.Begin); 71 defaultMethod.Erase(strm, dataSize, prng, chainCallbackHandler); 72 baseCompleted = 0.5F; 67 method.Erase(strm, dataSize, prng, callback); 73 68 74 69 //Seek to the end - 16kb, and write. 75 70 strm.Seek(-dataSize, SeekOrigin.End); 76 defaultMethod.Erase(strm, long.MaxValue, prng, chainCallbackHandler); 71 method.Erase(strm, long.MaxValue, prng, callback); 72 } 73 74 private ErasureMethod Method 75 { 76 get 77 { 78 //Try to retrieve the default erasure method. 79 ErasureMethod defaultMethod = ErasureMethodManager.GetInstance( 80 Globals.Settings.DefaultFileErasureMethod); 81 82 //If we are the default, use the default pseudorandom pass. 83 if (defaultMethod.GUID == GUID) 84 defaultMethod = ErasureMethodManager.GetInstance(new Guid( 85 "{BF8BA267-231A-4085-9BF9-204DE65A6641}")); 86 87 return defaultMethod; 88 } 77 89 } 78 90
Note: See TracChangeset
for help on using the changeset viewer.
