- Timestamp:
- Apr 2, 2016, 1:06:34 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/CoolDisk.lpi
r12 r13 83 83 </Item5> 84 84 </RequiredPackages> 85 <Units Count="1 1">85 <Units Count="10"> 86 86 <Unit0> 87 87 <Filename Value="CoolDisk.lpr"/> … … 136 136 <IsPartOfProject Value="True"/> 137 137 </Unit9> 138 <Unit10>139 <Filename Value="Form/UFormDrive.pas"/>140 <IsPartOfProject Value="True"/>141 <ComponentName Value="FormDrive"/>142 <ResourceBaseClass Value="Form"/>143 </Unit10>144 138 </Units> 145 139 </ProjectOptions> -
trunk/CoolDisk.lpr
r12 r13 10 10 Forms, tachartlazaruspkg, UFormBenchmark, UProject, 11 11 UConfig, UBlockMap, UDriveScan, Common, TemplateGenerics, UFormOperation, 12 UFormProject, UFormMain, UPhysDrive, UFormDrive 13 { you can add units after this }; 12 UFormProject, UFormMain, UPhysDrive; 14 13 15 14 {$R *.res} … … 22 21 Application.CreateForm(TFormOperation, FormOperation); 23 22 Application.CreateForm(TFormProject, FormProject); 24 Application.CreateForm(TFormDrive, FormDrive);25 23 Application.Run; 26 24 end. -
trunk/Form/UFormMain.lfm
r12 r13 9 9 Menu = MainMenu1 10 10 OnClose = FormClose 11 OnCloseQuery = FormCloseQuery 11 12 OnCreate = FormCreate 12 13 OnDestroy = FormDestroy … … 14 15 LCLVersion = '1.7' 15 16 object ButtonScan: TButton 16 Left = 1 2017 Left = 16 17 18 Height = 25 18 Top = 5619 Top = 104 19 20 Width = 75 20 21 Action = AScanStart … … 23 24 object Image1: TImage 24 25 Left = 592 25 Height = 8 7826 Top = 1026 Height = 848 27 Top = 40 27 28 Width = 1092 28 29 Anchors = [akTop, akLeft, akRight, akBottom] … … 37 38 ParentColor = False 38 39 end 39 object Label BlockSize: TLabel40 object LabelSectorSize: TLabel 40 41 Left = 256 41 42 Height = 24 … … 45 46 ParentColor = False 46 47 end 47 object Label BlockCount: TLabel48 object LabelSectorCount: TLabel 48 49 Left = 256 49 50 Height = 24 … … 158 159 end 159 160 object ButtonScan1: TButton 160 Left = 17161 Left = 440 161 162 Height = 25 162 Top = 56163 Width = 93163 Top = 48 164 Width = 120 164 165 Action = AProjectOptions 165 166 TabOrder = 1 166 167 end 167 168 object ButtonScan2: TButton 168 Left = 200169 Left = 104 169 170 Height = 25 170 Top = 56171 Top = 104 171 172 Width = 75 172 173 Action = AScanStop … … 190 191 end 191 192 object Button2: TButton 192 Left = 286193 Left = 192 193 194 Height = 25 194 Top = 56195 Top = 104 195 196 Width = 107 196 197 Action = AScanContinue … … 235 236 end 236 237 object Button3: TButton 237 Left = 16238 Left = 312 238 239 Height = 25 239 Top = 96240 Width = 1 87240 Top = 104 241 Width = 112 241 242 Action = AOperationOptions 242 Caption = 'Options options'243 243 TabOrder = 5 244 244 end 245 245 object ComboBoxDrive: TComboBox 246 Left = 15246 Left = 8 247 247 Height = 38 248 Top = 8249 Width = 4 64248 Top = 40 249 Width = 416 250 250 ItemHeight = 0 251 251 OnChange = ComboBoxDriveChange … … 253 253 TabOrder = 6 254 254 end 255 object ToolBar1: TToolBar 256 Left = 0 257 Height = 26 258 Top = 0 259 Width = 1703 260 Caption = 'ToolBar1' 261 Images = ImageList1 262 TabOrder = 7 263 object ToolButton1: TToolButton 264 Left = 1 265 Top = 2 266 Action = AScanStart 267 end 268 object ToolButton2: TToolButton 269 Left = 24 270 Top = 2 271 Action = AScanStop 272 end 273 object ToolButton3: TToolButton 274 Left = 47 275 Top = 2 276 Action = AScanContinue 277 end 278 end 255 279 object Timer1: TTimer 256 280 Interval = 500 … … 274 298 OnExecute = AProjectOptionsExecute 275 299 end 276 object A BrowseDisk: TAction300 object ADriveSelect: TAction 277 301 Caption = 'Select...' 278 302 end … … 319 343 end 320 344 object MainMenu1: TMainMenu 345 Images = ImageList1 321 346 left = 672 322 347 top = 504 … … 374 399 top = 160 375 400 end 401 object ImageList1: TImageList 402 left = 672 403 top = 573 404 end 376 405 end -
trunk/Form/UFormMain.pas
r12 r13 14 14 15 15 TFormMain = class(TForm) 16 A BrowseDisk: TAction;16 ADriveSelect: TAction; 17 17 AOperationOptions: TAction; 18 18 AFileClose: TAction; … … 34 34 ComboBoxDrive: TComboBox; 35 35 Image1: TImage; 36 ImageList1: TImageList; 36 37 Label1: TLabel; 37 38 Label10: TLabel; … … 45 46 Label8: TLabel; 46 47 LabelElapsedTime: TLabel; 47 Label BlockSize: TLabel;48 Label BlockCount: TLabel;48 LabelSectorSize: TLabel; 49 LabelSectorCount: TLabel; 49 50 LabelBlockCurrent: TLabel; 50 51 LabelBlockDamaged: TLabel; … … 73 74 SaveDialog1: TSaveDialog; 74 75 Timer1: TTimer; 76 ToolBar1: TToolBar; 77 ToolButton1: TToolButton; 78 ToolButton2: TToolButton; 79 ToolButton3: TToolButton; 75 80 XMLConfig1: TXMLConfig; 76 81 procedure AExitExecute(Sender: TObject); … … 87 92 procedure ComboBoxDriveChange(Sender: TObject); 88 93 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 94 procedure FormCloseQuery(Sender: TObject; var CanClose: boolean); 89 95 procedure FormCreate(Sender: TObject); 90 96 procedure FormDestroy(Sender: TObject); … … 98 104 RedrawPending: Boolean; 99 105 LastProjectFileName: string; 106 LastDriveName: string; 100 107 procedure ReloadOperationList; 101 108 procedure ProjectOpen(FileName: string); … … 107 114 public 108 115 DriveList: TDriveList; 109 DriveScan: TDriveScan;110 116 Project: TProject; 111 117 procedure SaveConfig; … … 126 132 127 133 resourcestring 128 S ProjectModified= '(modified)';134 SModifiedFlag = '(modified)'; 129 135 SNewProject = 'New project'; 130 136 SSelectDriveForScan = 'Select drive for scan'; … … 132 138 SSaveProject = 'Save scan project'; 133 139 SBytes = 'bytes'; 140 SProjectModified = 'Project modified'; 141 SProjectModifiedQuestion = 'Project was modified. Do you want to save it?'; 134 142 135 143 { TFormMain } … … 175 183 procedure TFormMain.AScanStopExecute(Sender: TObject); 176 184 begin 177 DriveScan.Stop; 178 UpdateInterface; 185 if Assigned(Project) and Assigned(Project.CurrentScan) then begin 186 Project.CurrentScan.Stop; 187 UpdateInterface; 188 end; 179 189 end; 180 190 181 191 procedure TFormMain.ComboBoxDriveChange(Sender: TObject); 182 192 begin 183 DriveScan.SectorCount := TDriveInfo(DriveList[ComboBoxDrive.ItemIndex]).SectorCount; 184 DriveScan.DriveName := TDriveInfo(DriveList[ComboBoxDrive.ItemIndex]).Path; 185 DriveScan.SectorStart := 0; 186 DriveScan.SectorEnd := DriveScan.SectorCount - 1; 193 if Project.DriveInfo.Path <> TDriveInfo(ComboBoxDrive.Items.Objects[ComboBoxDrive.ItemIndex]).Path then begin 194 Project.DriveInfo.Assign(TDriveInfo(ComboBoxDrive.Items.Objects[ComboBoxDrive.ItemIndex])); 195 Project.Modified := True; 196 Project.CurrentScan.SectorCount := Project.DriveInfo.SectorCount; 197 Project.CurrentScan.SectorSize := Project.DriveInfo.SectorSize; 198 Project.CurrentScan.SectorStart := 0; 199 Project.CurrentScan.SectorEnd := Project.CurrentScan.SectorCount - 1; 200 Project.CurrentScan.Reset; 201 UpdateInterface; 202 Redraw; 203 end; 187 204 end; 188 205 … … 190 207 begin 191 208 LastBlockPos := 0; 192 DriveScan.DriveName := TDriveInfo(DriveList[ComboBoxDrive.ItemIndex]).Path;193 DriveScan.Reset;194 DriveScan.SectorSize := Project.SectorSize;195 DriveScan.OnChange := DriveScanChange;196 DriveScan.OnTerminate := DriveScanTerminate;197 DriveScan.Start;209 Project.CurrentScan.DriveName := Project.DriveInfo.Path; 210 Project.CurrentScan.SectorSize := Project.DriveInfo.SectorSize; 211 Project.CurrentScan.Reset; 212 Project.CurrentScan.OnChange := DriveScanChange; 213 Project.CurrentScan.OnTerminate := DriveScanTerminate; 214 Project.CurrentScan.Start; 198 215 Project.Modified := True; 199 216 UpdateInterface; … … 212 229 procedure TFormMain.AScanContinueExecute(Sender: TObject); 213 230 begin 214 DriveScan.Start;231 Project.CurrentScan.Start; 215 232 Project.Modified := True; 216 233 UpdateInterface; … … 224 241 procedure TFormMain.AFileCloseExecute(Sender: TObject); 225 242 begin 226 DriveScan := nil;227 243 FreeAndNil(Project); 228 244 UpdateInterface; … … 236 252 Project.Modified := False; 237 253 Project.Scans.Add(TDriveScan.Create); 238 DriveScan := TDriveScan(Project.Scans[0]); 239 240 DriveScan.SectorStart:= 0;241 DriveScan.SectorEnd := DriveScan.SectorCount - 1;242 DriveScan.Reset; 254 255 ComboBoxDrive.ItemIndex := DriveList.IndexOf(DriveList.FindByModel(Project.DriveInfo.Model)); 256 if (ComboBoxDrive.ItemIndex = -1) and (ComboBoxDrive.Items.Count > 0) then ComboBoxDrive.ItemIndex := 0; 257 ComboBoxDriveChange(Self); 258 243 259 Redraw; 244 260 UpdateInterface; … … 279 295 procedure TFormMain.AOperationOptionsExecute(Sender: TObject); 280 296 begin 281 FormOperation.Load( DriveScan);297 FormOperation.Load(Project.CurrentScan); 282 298 if FormOperation.ShowModal = mrOk then begin 283 FormOperation.Save( DriveScan);299 FormOperation.Save(Project.CurrentScan); 284 300 Project.Modified := True; 285 301 UpdateInterface; … … 291 307 AFileClose.Execute; 292 308 SaveConfig; 309 end; 310 311 procedure TFormMain.FormCloseQuery(Sender: TObject; var CanClose: boolean); 312 var 313 R: TModalResult; 314 begin 315 if Assigned(Project) and Project.Modified then begin 316 R := MessageDlg(SProjectModified, SProjectModifiedQuestion, mtConfirmation, [mbYes, mbNo, mbCancel], 0); 317 if R = mrCancel then begin 318 CanClose := False; 319 Exit; 320 end else 321 if R = mrYes then begin 322 AFileSave.Execute; 323 end; 324 end; 293 325 end; 294 326 … … 315 347 Picture.Bitmap.SetSize(Width, Height); 316 348 try 317 DriveScan.Lock.Acquire;349 Project.CurrentScan.Lock.Acquire; 318 350 try 319 351 Picture.Bitmap.BeginUpdate(True); 320 DriveScan.BlockMap.Draw(Picture.Bitmap.Canvas);352 Project.CurrentScan.BlockMap.Draw(Picture.Bitmap.Canvas); 321 353 finally 322 354 Picture.Bitmap.EndUpdate; 323 355 end; 324 LabelSize.Caption := PrefixMultiplier.Add(DriveScan.BlockMap.SectorCount * DriveScan.SectorSize, 325 BasePrefixMultipliers, SBytes); 326 LabelSectorPerBlock.Caption := IntToStr(DriveScan.BlockMap.SectorPerBlock); 327 LabelBlockSize.Caption := IntToStr(DriveScan.SectorSize) + ' ' + SBytes; 328 LabelBlockCount.Caption := IntToStr(DriveScan.BlockMap.SectorCount); 329 LabelBlockCurrent.Caption := IntToStr(DriveScan.SectorCurrent); 330 LabelBlockDamaged.Caption := IntToStr(DriveScan.DamagedBlockCount); 356 LabelSectorPerBlock.Caption := IntToStr(Project.CurrentScan.BlockMap.SectorPerBlock); 357 LabelBlockCurrent.Caption := IntToStr(Project.CurrentScan.SectorCurrent); 358 LabelBlockDamaged.Caption := IntToStr(Project.CurrentScan.DamagedBlockCount); 331 359 finally 332 DriveScan.Lock.Release;360 Project.CurrentScan.Lock.Release; 333 361 end; 334 362 RedrawPending := False; 335 363 end; 336 364 try 337 DriveScan.Lock.Acquire;338 if not DriveScan.Terminated then begin339 LabelElapsedTime.Caption := TimeToStr( DriveScan.GetElapsedTime);340 LabelEstimatedTime.Caption := TimeToStr((Now - DriveScan.TimeStart) /341 DriveScan.SectorCurrent * (DriveScan.BlockMap.SectorCount - DriveScan.SectorCurrent));342 LabelIOSpeed.Caption := PrefixMultiplier.Add(( DriveScan.SectorCurrent - LastBlockPos) *343 DriveScan.SectorSize / (Timer1.Interval / 1000), BasePrefixMultipliers, 'B/s');344 LastBlockPos := DriveScan.SectorCurrent;365 Project.CurrentScan.Lock.Acquire; 366 if not Project.CurrentScan.Terminated then begin 367 LabelElapsedTime.Caption := TimeToStr(Project.CurrentScan.GetElapsedTime); 368 LabelEstimatedTime.Caption := TimeToStr((Now - Project.CurrentScan.TimeStart) / 369 Project.CurrentScan.SectorCurrent * (Project.CurrentScan.BlockMap.SectorCount - Project.CurrentScan.SectorCurrent)); 370 LabelIOSpeed.Caption := PrefixMultiplier.Add((Project.CurrentScan.SectorCurrent - LastBlockPos) * 371 Project.CurrentScan.SectorSize / (Timer1.Interval / 1000), BasePrefixMultipliers, 'B/s'); 372 LastBlockPos := Project.CurrentScan.SectorCurrent; 345 373 end else begin 346 374 LabelElapsedTime.Caption := ''; … … 349 377 end; 350 378 finally 351 DriveScan.Lock.Release;379 Project.CurrentScan.Lock.Release; 352 380 end; 353 381 end else … … 367 395 Title: string; 368 396 begin 369 if Assigned(DriveScan) then begin 370 AScanStart.Enabled := DriveScan.Terminated = True; 371 AScanStop.Enabled := DriveScan.Terminated = False; 372 AScanContinue.Enabled := (DriveScan.Terminated = True) and (DriveScan.SectorCurrent > DriveScan.SectorStart) and 373 (DriveScan.SectorCurrent < DriveScan.SectorEnd); 397 if Assigned(Project) and Assigned(Project.CurrentScan) then begin 398 AScanStart.Enabled := Project.CurrentScan.Terminated = True; 399 AScanStop.Enabled := Project.CurrentScan.Terminated = False; 400 AScanContinue.Enabled := (Project.CurrentScan.Terminated = True) and 401 (Project.CurrentScan.SectorCurrent > Project.CurrentScan.SectorStart) and 402 (Project.CurrentScan.SectorCurrent < Project.CurrentScan.SectorEnd); 403 end else begin 404 AScanStart.Enabled := False; 405 AScanStop.Enabled := False; 406 AScanContinue.Enabled := False; 374 407 end; 375 408 AFileSave.Enabled := Assigned(Project) and Project.Modified; 376 409 AFileSaveAs.Enabled := Assigned(Project); 377 410 AFileClose.Enabled := Assigned(Project); 411 ComboBoxDrive.Enabled := Assigned(Project); 412 AProjectOptions.Enabled := Assigned(Project);; 413 AOperationOptions.Enabled := Assigned(Project);; 378 414 ReloadOperationList; 379 415 … … 383 419 Title := Title + Application.Title; 384 420 if Assigned(Project) and Project.Modified then 385 Title := Title + ' ' + S ProjectModified;421 Title := Title + ' ' + SModifiedFlag; 386 422 Caption := Title; 423 424 if Assigned(Project) then begin 425 LabelSize.Caption := PrefixMultiplier.Add(Project.DriveInfo.Size, 426 BasePrefixMultipliers, SBytes); 427 LabelSectorCount.Caption := IntToStr(Project.DriveInfo.SectorCount); 428 LabelSectorSize.Caption := IntToStr(Project.DriveInfo.SectorSize) + ' ' + SBytes; 429 end else begin 430 LabelSize.Caption := ''; 431 LabelSectorCount.Caption := ''; 432 LabelSectorSize.Caption := ''; 433 end; 387 434 end; 388 435 389 436 procedure TFormMain.SaveConfig; 390 437 begin 391 XMLConfig1.SetValue('DriveName', TDriveInfo(DriveList[ComboBoxDrive.ItemIndex]).Model);438 XMLConfig1.SetValue('DriveName', LastDriveName); 392 439 XMLConfig1.SetValue('LastProjectFileName', LastProjectFileName); 393 440 end; … … 395 442 procedure TFormMain.LoadConfig; 396 443 begin 397 ComboBoxDrive.ItemIndex := DriveList.IndexOf(DriveList.FindByModel(XMLConfig1.GetValue('DriveName', '')));444 LastDriveName := XMLConfig1.GetValue('DriveName', ''); 398 445 LastProjectFileName := XMLConfig1.GetValue('LastProjectFileName', ''); 399 446 end; … … 418 465 AFileNew.Execute; 419 466 Project.LoadFromFile(FileName); 467 ComboBoxDrive.ItemIndex := DriveList.IndexOf(DriveList.FindByModel(Project.DriveInfo.Model)); 468 if (ComboBoxDrive.ItemIndex = -1) and (ComboBoxDrive.Items.Count > 0) then ComboBoxDrive.ItemIndex := 0; 420 469 LastProjectFileName := FileName; 421 470 UpdateInterface; … … 438 487 begin 439 488 DriveList.Detect; 440 while ComboBoxDrive.Items.Count > DriveList.Count do 441 ComboBoxDrive.Items.Delete(ComboBoxDrive.Items.Count - 1); 442 while ComboBoxDrive.Items.Count < DriveList.Count do 443 ComboBoxDrive.Items.Add(''); 444 for I := 0 to DriveList.Count - 1 do 445 ComboBoxDrive.Items[I] := TDriveInfo(DriveList[I]).Model + ' (' + 446 PrefixMultiplier.Add(TDriveInfo(DriveList[I]).Size, BasePrefixMultipliers, 'B') + ')'; 489 DriveList.LoadToStrings(ComboBoxDrive.Items); 447 490 end; 448 491 -
trunk/Form/UFormOperation.lfm
r11 r13 71 71 Width = 138 72 72 MaxValue = 100000 73 MinValue = 174 73 OnChange = SpinEditFirstSectorChange 75 74 TabOrder = 4 … … 82 81 Width = 138 83 82 MaxValue = 100000 84 MinValue = 185 83 OnChange = SpinEditLastSectorChange 86 84 TabOrder = 5 -
trunk/Form/UFormProject.lfm
r11 r13 1 1 object FormProject: TFormProject 2 2 Left = 537 3 Height = 3 404 Top = 4 925 Width = 4613 Height = 392 4 Top = 440 5 Width = 612 6 6 Caption = 'Project settings' 7 ClientHeight = 3 408 ClientWidth = 4617 ClientHeight = 392 8 ClientWidth = 612 9 9 LCLVersion = '1.7' 10 10 object SpinEditSectorSize: TSpinEdit 11 11 Left = 192 12 12 Height = 34 13 Top = 5613 Top = 152 14 14 Width = 101 15 15 MaxValue = 100000 … … 21 21 Left = 16 22 22 Height = 24 23 Top = 6423 Top = 160 24 24 Width = 101 25 25 Caption = 'Sector size:' … … 44 44 TabOrder = 2 45 45 end 46 object Edit 1: TEdit46 object EditName: TEdit 47 47 Left = 192 48 48 Height = 34 … … 50 50 Width = 240 51 51 TabOrder = 3 52 Text = 'Edit1'53 52 end 54 53 object Label2: TLabel … … 60 59 ParentColor = False 61 60 end 61 object ComboBoxDrive: TComboBox 62 Left = 192 63 Height = 38 64 Top = 56 65 Width = 384 66 ItemHeight = 0 67 Style = csDropDownList 68 TabOrder = 4 69 end 70 object Label3: TLabel 71 Left = 16 72 Height = 24 73 Top = 64 74 Width = 53 75 Caption = 'Drive:' 76 ParentColor = False 77 end 78 object Label4: TLabel 79 Left = 16 80 Height = 24 81 Top = 112 82 Width = 119 83 Caption = 'Sector count:' 84 ParentColor = False 85 end 86 object LabelSectorCount: TLabel 87 Left = 192 88 Height = 24 89 Top = 112 90 Width = 15 91 Caption = ' ' 92 ParentColor = False 93 end 62 94 end -
trunk/Form/UFormProject.pas
r11 r13 16 16 Button1: TButton; 17 17 Button2: TButton; 18 Edit1: TEdit; 18 ComboBoxDrive: TComboBox; 19 EditName: TEdit; 19 20 Label1: TLabel; 20 21 Label2: TLabel; 22 Label3: TLabel; 23 Label4: TLabel; 24 LabelSectorCount: TLabel; 21 25 SpinEditSectorSize: TSpinEdit; 22 26 private … … 33 37 {$R *.lfm} 34 38 39 uses 40 UFormMain; 41 35 42 { TFormProject } 36 43 37 44 procedure TFormProject.Load(Project: TProject); 38 45 begin 39 Edit1.Text := Project.Name; 40 SpinEditSectorSize.Value := Project.SectorSize; 46 FormMain.DriveList.LoadToStrings(ComboBoxDrive.Items); 47 EditName.Text := Project.Name; 48 SpinEditSectorSize.Value := Project.DriveInfo.SectorSize; 49 ComboBoxDrive.ItemIndex := FormMain.DriveList.IndexOf(FormMain.DriveList.FindByModel(Project.DriveInfo.Model)); 41 50 end; 42 51 43 52 procedure TFormProject.Save(Project: TProject); 44 53 begin 45 Project.Name := Edit 1.Text;46 Project. SectorSize := SpinEditSectorSize.Value;54 Project.Name := EditName.Text; 55 Project.DriveInfo.SectorSize := SpinEditSectorSize.Value; 47 56 end; 48 57 -
trunk/Packages/Common/UXMLUtils.pas
r4 r13 12 12 function DateTimeToXMLTime(Value: TDateTime; ApplyLocalBias: Boolean = True): WideString; 13 13 procedure WriteInteger(Node: TDOMNode; Name: string; Value: Integer); 14 procedure WriteInt64(Node: TDOMNode; Name: string; Value: Int64); 14 15 procedure WriteBoolean(Node: TDOMNode; Name: string; Value: Boolean); 15 16 procedure WriteString(Node: TDOMNode; Name: string; Value: string); 16 17 procedure WriteDateTime(Node: TDOMNode; Name: string; Value: TDateTime); 17 18 function ReadInteger(Node: TDOMNode; Name: string; DefaultValue: Integer): Integer; 19 function ReadInt64(Node: TDOMNode; Name: string; DefaultValue: Int64): Int64; 18 20 function ReadBoolean(Node: TDOMNode; Name: string; DefaultValue: Boolean): Boolean; 19 21 function ReadString(Node: TDOMNode; Name: string; DefaultValue: string): string; … … 142 144 end; 143 145 146 procedure WriteInt64(Node: TDOMNode; Name: string; Value: Int64); 147 var 148 NewNode: TDOMNode; 149 begin 150 NewNode := Node.OwnerDocument.CreateElement(Name); 151 NewNode.TextContent := IntToStr(Value); 152 Node.AppendChild(NewNode); 153 end; 154 144 155 procedure WriteBoolean(Node: TDOMNode; Name: string; Value: Boolean); 145 156 var … … 170 181 171 182 function ReadInteger(Node: TDOMNode; Name: string; DefaultValue: Integer): Integer; 183 var 184 NewNode: TDOMNode; 185 begin 186 Result := DefaultValue; 187 NewNode := Node.FindNode(Name); 188 if Assigned(NewNode) then 189 Result := StrToInt(NewNode.TextContent); 190 end; 191 192 function ReadInt64(Node: TDOMNode; Name: string; DefaultValue: Int64): Int64; 172 193 var 173 194 NewNode: TDOMNode; -
trunk/UDriveScan.pas
r12 r13 39 39 Lock: TCriticalSection; 40 40 BlockMap: TBlockMap; 41 SectorSize: Integer;42 41 TimeStart: TDateTime; 43 42 TimeEnd: TDateTime; … … 46 45 Mode: TRunMode; 47 46 WritePattern: Byte; 47 SectorSize: Integer; 48 48 SectorStart: Integer; 49 49 SectorEnd: Integer; … … 257 257 WriteDateTime(Node, 'TimeStart', TimeStart); 258 258 WriteDateTime(Node, 'TimeEnd', TimeEnd); 259 WriteInteger(Node, 'SectorSize', SectorSize); 260 WriteInteger(Node, 'SectorCount', SectorCount); 259 261 WriteInteger(Node, 'SectorStart', SectorStart); 260 262 WriteInteger(Node, 'SectorEnd', SectorEnd); … … 277 279 TimeStart := ReadDateTime(Node, 'TimeStart', 0); 278 280 TimeEnd := ReadDateTime(Node, 'TimeEnd', 0); 279 FSectorCurrent := ReadInteger(Node, 'SectorCurrent', 0); 281 SectorSize := ReadInteger(Node, 'SectorSize', 512); 282 SectorCount := ReadInteger(Node, 'SectorCount', 0); 280 283 SectorStart := ReadInteger(Node, 'SectorStart', 0); 281 284 SectorEnd := ReadInteger(Node, 'SectorEnd', SectorCount - 1); 285 FSectorCurrent := ReadInteger(Node, 'SectorCurrent', 0); 282 286 283 287 NewNode := FindNode('SectorMap'); -
trunk/UPhysDrive.pas
r12 r13 9 9 10 10 type 11 12 { TDriveInfo } 13 11 14 TDriveInfo = class 12 15 Model: string; 13 16 Size: Int64; 14 17 SectorCount: Int64; 18 SectorSize: Integer; 15 19 Path: string; 20 procedure Assign(Source: TDriveInfo); 16 21 end; 17 22 … … 20 25 TDriveList = class(TObjectList) 21 26 function FindByModel(Model: string): TDriveInfo; 27 procedure LoadToStrings(Strings: TStrings); 22 28 procedure Detect; 23 29 end; 24 30 25 31 implementation 32 33 uses 34 UPrefixMultiplier; 35 36 { TDriveInfo } 37 38 procedure TDriveInfo.Assign(Source: TDriveInfo); 39 begin 40 Path := Source.Path; 41 Model := Source.Model; 42 Size := Source.Size; 43 SectorCount := Source.SectorCount; 44 SectorSize := Source.SectorSize; 45 end; 26 46 27 47 { TDriveList } … … 35 55 if I < Count then Result := TDriveInfo(Items[I]) 36 56 else Result := nil; 57 end; 58 59 procedure TDriveList.LoadToStrings(Strings: TStrings); 60 var 61 I: Integer; 62 PrefixMultiplier: TPrefixMultiplier; 63 begin 64 PrefixMultiplier := TPrefixMultiplier.Create; 65 try 66 while Strings.Count > Count do 67 Strings.Delete(Strings.Count - 1); 68 while Strings.Count < Count do 69 Strings.Add(''); 70 for I := 0 to Count - 1 do begin 71 Strings[I] := TDriveInfo(Items[I]).Model + ' (' + 72 PrefixMultiplier.Add(TDriveInfo(Items[I]).Size, BasePrefixMultipliers, 'B') + ')'; 73 Strings.Objects[I] := Items[I]; 74 end; 75 finally 76 PrefixMultiplier.Free; 77 end; 37 78 end; 38 79 … … 57 98 NewDriveInfo := TDriveInfo.Create; 58 99 NewDriveInfo.Model := Trim(LoadFileToStr(List[I] + '/device/model')); 59 NewDriveInfo.SectorCount := StrToInt(Trim(LoadFileToStr(List[I] + '/size'))); 60 NewDriveInfo.Size := NewDriveInfo.SectorCount * 512; 100 NewDriveInfo.SectorSize := StrToInt(Trim(LoadFileToStr(List[I] + '/queue/physical_block_size'))); 101 NewDriveInfo.SectorCount := StrToInt(Trim(LoadFileToStr(List[I] + '/size'))) * 512 div NewDriveInfo.SectorSize; 102 NewDriveInfo.Size := NewDriveInfo.SectorCount * NewDriveInfo.SectorSize; 61 103 NewDriveInfo.Path := '/dev/' + ExtractFileName(List[I]); 62 104 Add(NewDriveInfo); -
trunk/UProject.pas
r10 r13 6 6 7 7 uses 8 Classes, SysUtils, Contnrs, DOM, XMLRead, XMLWrite, UXMLUtils, UDriveScan; 8 Classes, SysUtils, Contnrs, DOM, XMLRead, XMLWrite, UXMLUtils, UDriveScan, 9 UPhysDrive; 9 10 10 11 type … … 13 14 14 15 TProject = class 16 private 17 function GetCurrentScan: TDriveScan; 18 function GetSectorCount: Integer; 19 public 15 20 Name: string; 16 21 FileName: string; 17 SectorSize: Integer;18 SectorCount: Integer;19 22 Modified: Boolean; 20 23 Scans: TDriveScanList; 21 Drive Name: string;24 DriveInfo: TDriveInfo; 22 25 constructor Create; 23 26 destructor Destroy; override; 24 27 procedure LoadFromFile(FileName: string); 25 28 procedure SaveToFile(FileName: string); 29 property SectorCount: Integer read GetSectorCount; 30 property CurrentScan: TDriveScan read GetCurrentScan; 26 31 end; 27 32 … … 35 40 { TProject } 36 41 42 function TProject.GetCurrentScan: TDriveScan; 43 begin 44 if Scans.Count > 0 then Result := TDriveScan(Scans[Scans.Count - 1]) 45 else Result := nil; 46 end; 47 48 function TProject.GetSectorCount: Integer; 49 begin 50 Result := DriveInfo.SectorCount; 51 end; 52 37 53 constructor TProject.Create; 38 54 begin 39 SectorSize := 4096;40 55 Scans := TDriveScanList.Create; 56 DriveInfo := TDriveInfo.Create; 41 57 end; 42 58 43 59 destructor TProject.Destroy; 44 60 begin 61 FreeAndNil(DriveInfo); 45 62 FreeAndNil(Scans); 46 63 inherited Destroy; … … 59 76 AppendChild(RootNode); 60 77 with RootNode do begin 61 WriteInteger(RootNode, 'SectorSize', SectorSize); 62 WriteInteger(RootNode, 'SectorCount', SectorCount); 63 WriteString(RootNode, 'DriveName', DriveName); 78 WriteInteger(RootNode, 'SectorCount', DriveInfo.SectorCount); 79 WriteInteger(RootNode, 'SectorSize', DriveInfo.SectorSize); 80 WriteString(RootNode, 'DriveName', DriveInfo.Model); 81 WriteString(RootNode, 'DrivePath', DriveInfo.Path); 82 WriteInt64(RootNode, 'DriveSize', DriveInfo.Size); 64 83 65 84 NewNode := OwnerDocument.CreateElement('Scans'); … … 89 108 RootNode := Doc.DocumentElement; 90 109 with RootNode do begin 91 SectorSize := ReadInteger(RootNode, 'SectorSize', 4096); 92 SectorCount := ReadInteger(RootNode, 'SectorCount', 0); 93 DriveName := ReadString(RootNode, 'DriveName', ''); 110 DriveInfo.SectorSize := ReadInteger(RootNode, 'SectorSize', 4096); 111 DriveInfo.SectorCount := ReadInteger(RootNode, 'SectorCount', 0); 112 DriveInfo.Model := ReadString(RootNode, 'DriveName', ''); 113 DriveInfo.Path := ReadString(RootNode, 'DrivePath', ''); 114 DriveInfo.Size := ReadInt64(RootNode, 'DriveSize', 0); 94 115 95 116 NewNode := FindNode('Scans');
Note:
See TracChangeset
for help on using the changeset viewer.