Changeset 2020 for trunk/eraser
- Timestamp:
- 5/3/2010 1:01:55 PM (3 years ago)
- Location:
- trunk/eraser
- Files:
-
- 4 edited
-
Eraser.Manager/Eraser.Manager.csproj (modified) (1 diff)
-
Eraser.Manager/ErasureTarget.cs (modified) (9 diffs)
-
Eraser/TaskDataSelectionForm.cs (modified) (1 diff)
-
Eraser/TaskPropertiesForm.cs (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/eraser/Eraser.Manager/Eraser.Manager.csproj
r1902 r2020 67 67 <Compile Include="DirectExecutor.cs" /> 68 68 <Compile Include="EntropySource.cs" /> 69 <Compile Include="ErasureTarget.cs" /> 69 70 <Compile Include="Exception.cs" /> 70 71 <Compile Include="Executor.cs" /> -
trunk/eraser/Eraser.Manager/ErasureTarget.cs
r2018 r2020 46 46 Guid methodGuid = (Guid)info.GetValue("Method", typeof(Guid)); 47 47 if (methodGuid == Guid.Empty) 48 method = ErasureMethodRegistrar.Default;48 Method = ErasureMethodRegistrar.Default; 49 49 else 50 method = ManagerLibrary.Instance.ErasureMethodRegistrar[methodGuid];50 Method = ManagerLibrary.Instance.ErasureMethodRegistrar[methodGuid]; 51 51 } 52 52 … … 54 54 public virtual void GetObjectData(SerializationInfo info, StreamingContext context) 55 55 { 56 info.AddValue("Method", method.Guid);56 info.AddValue("Method", Method.Guid); 57 57 } 58 58 #endregion … … 63 63 protected ErasureTarget() 64 64 { 65 } 66 67 /// <summary> 68 /// The method used for erasing the file. If the variable is equal to 69 /// ErasureMethodManager.Default then the default is queried for the 70 /// task type. Check the <see cref="MethodDefined"/> property to see if 71 /// this variable was set on deliberately or if the result of the get 72 /// call is from the inferred default. 73 /// </summary> 74 public virtual ErasureMethod Method 75 { 76 get 77 { 78 return method; 79 } 80 set 81 { 82 method = value; 83 MethodDefined = method != ErasureMethodRegistrar.Default; 84 } 85 } 86 87 /// <summary> 88 /// Checks whether a method has been selected for this target. This is 89 /// because the Method property will return non-default erasure methods 90 /// only. 91 /// </summary> 92 public bool MethodDefined { get; private set; } 65 Method = ErasureMethodRegistrar.Default; 66 } 67 68 /// <summary> 69 /// The method used for erasing the file. 70 /// </summary> 71 public ErasureMethod Method 72 { 73 get; 74 set; 75 } 76 77 /// <summary> 78 /// Gets the effective erasure method for the current target (i.e., returns 79 /// the correct erasure method for cases where the <see cref="Method"/> 80 /// property is <see cref="ErasureMethodRegistrar.Default"/> 81 /// </summary> 82 /// <returns>The Erasure method which the target should be erased with. 83 /// This function will never return <see cref="ErasureMethodRegistrar.Default"/></returns> 84 public virtual ErasureMethod EffectiveMethod 85 { 86 get 87 { 88 if (Method != ErasureMethodRegistrar.Default) 89 return Method; 90 91 throw new InvalidOperationException("The effective method of the erasure " + 92 "target cannot be ErasureMethodRegistrar.Default"); 93 } 94 } 93 95 94 96 /// <summary> … … 104 106 get; 105 107 } 106 107 /// <summary>108 /// Retrieves the amount of data that needs to be written in order to109 /// complete the erasure.110 /// </summary>111 public abstract long TotalData112 {113 get;114 }115 116 /// <summary>117 /// Erasure method to use for the target.118 /// </summary>119 private ErasureMethod method;120 108 121 109 /// <summary> … … 156 144 : base() 157 145 { 158 Method = ErasureMethodRegistrar.Default;159 146 } 160 147 … … 219 206 public string Path { get; set; } 220 207 221 public sealed override ErasureMethod Method 222 { 223 get 224 { 225 if (base.MethodDefined) 226 return base.Method; 208 public sealed override ErasureMethod EffectiveMethod 209 { 210 get 211 { 212 if (Method == ErasureMethodRegistrar.Default) 213 return base.EffectiveMethod; 214 227 215 return ManagerLibrary.Instance.ErasureMethodRegistrar[ 228 216 ManagerLibrary.Settings.DefaultFileErasureMethod]; 229 }230 set231 {232 base.Method = value;233 217 } 234 218 } … … 243 227 (string.IsNullOrEmpty(directoryName) ? Path : directoryName) 244 228 : fileName; 245 }246 }247 248 public override long TotalData249 {250 get251 {252 long totalSize = 0;253 List<string> paths = GetPaths(out totalSize);254 return Method.CalculateEraseDataSize(paths, totalSize);255 229 } 256 230 } … … 286 260 : base() 287 261 { 288 Method = ErasureMethodRegistrar.Default;289 } 290 291 public override sealed ErasureMethod Method292 {293 get294 {295 if (base.MethodDefined)296 return base.Method; 262 } 263 264 public sealed override ErasureMethod EffectiveMethod 265 { 266 get 267 { 268 if (Method == ErasureMethodRegistrar.Default) 269 return base.EffectiveMethod; 270 297 271 return ManagerLibrary.Instance.ErasureMethodRegistrar[ 298 272 ManagerLibrary.Settings.DefaultUnusedSpaceErasureMethod]; 299 273 } 300 set301 {302 base.Method = value;303 }304 274 } 305 275 … … 307 277 { 308 278 get { return S._("Unused disk space ({0})", Drive); } 309 }310 311 public override long TotalData312 {313 get314 {315 VolumeInfo info = VolumeInfo.FromMountPoint(Drive);316 return Method.CalculateEraseDataSize(null, info.AvailableFreeSpace);317 }318 279 } 319 280 -
trunk/eraser/Eraser/TaskDataSelectionForm.cs
r1998 r2020 138 138 { 139 139 //Set the erasure method. 140 if (value.MethodDefined) 141 { 142 foreach (object item in method.Items) 143 if (((ErasureMethod)item).Guid == value.Method.Guid) 144 method.SelectedItem = item; 145 } 146 else 147 method.SelectedIndex = 0; 140 foreach (object item in method.Items) 141 if (((ErasureMethod)item).Guid == value.Method.Guid) 142 method.SelectedItem = item; 148 143 149 144 //Then the data to be erased. -
trunk/eraser/Eraser/TaskPropertiesForm.cs
r1967 r2020 141 141 { 142 142 ListViewItem item = data.Items.Add(target.UIText); 143 item.SubItems.Add(target.MethodDefined ? target.Method.Name : S._("(default)")); 143 item.SubItems.Add(target.Method == ErasureMethodRegistrar.Default ? 144 S._("(default)") : target.Method.Name); 144 145 item.Tag = target; 145 146 } … … 215 216 ErasureTarget target = form.Target; 216 217 ListViewItem item = data.Items.Add(target.UIText); 217 item.SubItems.Add(target.MethodDefined ? target.Method.Name : S._("(default)")); 218 item.SubItems.Add(target.Method == ErasureMethodRegistrar.Default ? 219 S._("(default)") : target.Method.Name); 218 220 item.Tag = target; 219 221 … … 244 246 item.Tag = target; 245 247 item.Text = target.UIText; 246 item.SubItems[1].Text = target.MethodDefined ? target.Method.Name : S._("(default)"); 248 item.SubItems[1].Text = target.Method == ErasureMethodRegistrar.Default ? 249 S._("(default)") : target.Method.Name; 247 250 } 248 251 }
Note: See TracChangeset
for help on using the changeset viewer.
