Changeset 12
- Timestamp:
- Apr 2, 2016, 11:08:30 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/CoolDisk.lpi
r10 r12 83 83 </Item5> 84 84 </RequiredPackages> 85 <Units Count=" 9">85 <Units Count="11"> 86 86 <Unit0> 87 87 <Filename Value="CoolDisk.lpr"/> … … 89 89 </Unit0> 90 90 <Unit1> 91 <Filename Value="UFormMain.pas"/>92 <IsPartOfProject Value="True"/>93 <ComponentName Value="FormMain"/>94 <HasResources Value="True"/>95 <ResourceBaseClass Value="Form"/>96 </Unit1>97 <Unit2>98 91 <Filename Value="Form/UFormBenchmark.pas"/> 99 92 <IsPartOfProject Value="True"/> … … 101 94 <HasResources Value="True"/> 102 95 <ResourceBaseClass Value="Form"/> 96 </Unit1> 97 <Unit2> 98 <Filename Value="UProject.pas"/> 99 <IsPartOfProject Value="True"/> 103 100 </Unit2> 104 101 <Unit3> 105 <Filename Value="UFormProject.pas"/> 102 <Filename Value="UConfig.pas"/> 103 <IsPartOfProject Value="True"/> 104 </Unit3> 105 <Unit4> 106 <Filename Value="UBlockMap.pas"/> 107 <IsPartOfProject Value="True"/> 108 </Unit4> 109 <Unit5> 110 <Filename Value="UDriveScan.pas"/> 111 <IsPartOfProject Value="True"/> 112 </Unit5> 113 <Unit6> 114 <Filename Value="Form/UFormOperation.pas"/> 115 <IsPartOfProject Value="True"/> 116 <ComponentName Value="FormOperation"/> 117 <HasResources Value="True"/> 118 <ResourceBaseClass Value="Form"/> 119 </Unit6> 120 <Unit7> 121 <Filename Value="Form/UFormMain.pas"/> 122 <IsPartOfProject Value="True"/> 123 <ComponentName Value="FormMain"/> 124 <HasResources Value="True"/> 125 <ResourceBaseClass Value="Form"/> 126 </Unit7> 127 <Unit8> 128 <Filename Value="Form/UFormProject.pas"/> 106 129 <IsPartOfProject Value="True"/> 107 130 <ComponentName Value="FormProject"/> 108 131 <HasResources Value="True"/> 109 132 <ResourceBaseClass Value="Form"/> 110 </Unit 3>111 <Unit 4>112 <Filename Value="UP roject.pas"/>133 </Unit8> 134 <Unit9> 135 <Filename Value="UPhysDrive.pas"/> 113 136 <IsPartOfProject Value="True"/> 114 </Unit 4>115 <Unit 5>116 <Filename Value=" UConfig.pas"/>137 </Unit9> 138 <Unit10> 139 <Filename Value="Form/UFormDrive.pas"/> 117 140 <IsPartOfProject Value="True"/> 118 </Unit5> 119 <Unit6> 120 <Filename Value="UBlockMap.pas"/> 121 <IsPartOfProject Value="True"/> 122 </Unit6> 123 <Unit7> 124 <Filename Value="UDriveScan.pas"/> 125 <IsPartOfProject Value="True"/> 126 </Unit7> 127 <Unit8> 128 <Filename Value="Form/UFormOperation.pas"/> 129 <IsPartOfProject Value="True"/> 130 <ComponentName Value="FormOperation"/> 141 <ComponentName Value="FormDrive"/> 131 142 <ResourceBaseClass Value="Form"/> 132 </Unit 8>143 </Unit10> 133 144 </Units> 134 145 </ProjectOptions> -
trunk/CoolDisk.lpr
r10 r12 8 8 {$ENDIF} 9 9 Interfaces, // this includes the LCL widgetset 10 Forms, tachartlazaruspkg, UFormMain, UFormBenchmark, UFormProject, UProject, 11 UConfig, UBlockMap, UDriveScan, Common, TemplateGenerics, UFormOperation 10 Forms, tachartlazaruspkg, UFormBenchmark, UProject, 11 UConfig, UBlockMap, UDriveScan, Common, TemplateGenerics, UFormOperation, 12 UFormProject, UFormMain, UPhysDrive, UFormDrive 12 13 { you can add units after this }; 13 14 … … 19 20 Application.CreateForm(TFormMain, FormMain); 20 21 Application.CreateForm(TFormBenchmark, FormBenchmark); 22 Application.CreateForm(TFormOperation, FormOperation); 21 23 Application.CreateForm(TFormProject, FormProject); 22 Application.CreateForm(TForm Operation, FormOperation);24 Application.CreateForm(TFormDrive, FormDrive); 23 25 Application.Run; 24 26 end. -
trunk/Form/UFormMain.lfm
r11 r12 173 173 TabOrder = 2 174 174 end 175 object Button1: TButton176 Left = 480177 Height = 25178 Top = 17179 Width = 91180 Action = ABrowseDisk181 TabOrder = 3182 end183 object EditDrive: TEdit184 Left = 16185 Height = 34186 Top = 8187 Width = 448188 TabOrder = 4189 end190 175 object Label10: TLabel 191 176 Left = 16 … … 210 195 Width = 107 211 196 Action = AScanContinue 212 TabOrder = 5197 TabOrder = 3 213 198 end 214 199 object ListView1: TListView … … 237 222 ReadOnly = True 238 223 RowSelect = True 239 TabOrder = 6224 TabOrder = 4 240 225 ViewStyle = vsReport 241 226 OnData = ListView1Data … … 256 241 Action = AOperationOptions 257 242 Caption = 'Options options' 258 TabOrder = 7 243 TabOrder = 5 244 end 245 object ComboBoxDrive: TComboBox 246 Left = 15 247 Height = 38 248 Top = 8 249 Width = 464 250 ItemHeight = 0 251 OnChange = ComboBoxDriveChange 252 Style = csDropDownList 253 TabOrder = 6 259 254 end 260 255 object Timer1: TTimer … … 281 276 object ABrowseDisk: TAction 282 277 Caption = 'Select...' 283 OnExecute = ABrowseDiskExecute284 278 end 285 279 object AExit: TAction -
trunk/Form/UFormMain.pas
r11 r12 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 9 Menus, ComCtrls, ExtCtrls, ActnList, dateutils, syncobjs, UProject, 10 UDriveScan, UPrefixMultiplier, XMLConf ;10 UDriveScan, UPrefixMultiplier, XMLConf, UPhysDrive; 11 11 12 12 type … … 27 27 AScanStop: TAction; 28 28 ActionList1: TActionList; 29 Button1: TButton;30 29 Button2: TButton; 31 30 Button3: TButton; … … 33 32 ButtonScan1: TButton; 34 33 ButtonScan2: TButton; 35 EditDrive: TEdit;34 ComboBoxDrive: TComboBox; 36 35 Image1: TImage; 37 36 Label1: TLabel; … … 75 74 Timer1: TTimer; 76 75 XMLConfig1: TXMLConfig; 77 procedure ABrowseDiskExecute(Sender: TObject);78 76 procedure AExitExecute(Sender: TObject); 79 77 procedure AFileCloseExecute(Sender: TObject); … … 87 85 procedure AScanStartExecute(Sender: TObject); 88 86 procedure AScanStopExecute(Sender: TObject); 87 procedure ComboBoxDriveChange(Sender: TObject); 89 88 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 90 89 procedure FormCreate(Sender: TObject); … … 100 99 LastProjectFileName: string; 101 100 procedure ReloadOperationList; 102 procedure CheckDrive;103 101 procedure ProjectOpen(FileName: string); 104 102 procedure DriveScanChange(Sender: TObject); … … 108 106 procedure UpdateInterface; 109 107 public 108 DriveList: TDriveList; 110 109 DriveScan: TDriveScan; 111 110 Project: TProject; … … 134 133 SBytes = 'bytes'; 135 134 136 const137 DefaultDriveName = '/dev/sda';138 139 135 { TFormMain } 140 136 141 137 procedure TFormMain.FormShow(Sender: TObject); 142 138 begin 139 Detect; 143 140 LoadConfig; 144 141 if FileExists(LastProjectFileName) then … … 171 168 begin 172 169 PrefixMultiplier := TPrefixMultiplier.Create; 173 EditDrive.Text := DefaultDriveName;174 170 XMLConfig1.Filename := 'config.xml'; 175 171 Project := nil; 172 DriveList := TDriveList.Create; 176 173 end; 177 174 … … 182 179 end; 183 180 181 procedure TFormMain.ComboBoxDriveChange(Sender: TObject); 182 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; 187 end; 188 184 189 procedure TFormMain.AScanStartExecute(Sender: TObject); 185 190 begin 186 191 LastBlockPos := 0; 187 DriveScan.DriveName := EditDrive.Text;192 DriveScan.DriveName := TDriveInfo(DriveList[ComboBoxDrive.ItemIndex]).Path; 188 193 DriveScan.Reset; 189 194 DriveScan.SectorSize := Project.SectorSize; … … 197 202 procedure TFormMain.AProjectOptionsExecute(Sender: TObject); 198 203 begin 199 CheckDrive;200 204 FormProject.Load(Project); 201 205 if FormProject.ShowModal = mrOk then begin … … 211 215 Project.Modified := True; 212 216 UpdateInterface; 213 end;214 215 procedure TFormMain.ABrowseDiskExecute(Sender: TObject);216 begin217 OpenDialog1.Title := SSelectDriveForScan;218 OpenDialog1.DefaultExt := '';219 OpenDialog1.FileName := EditDrive.Text;220 if OpenDialog1.Execute then221 EditDrive.Text := OpenDialog1.FileName;222 217 end; 223 218 … … 243 238 DriveScan := TDriveScan(Project.Scans[0]); 244 239 245 CheckDrive;246 240 DriveScan.SectorStart := 0; 247 241 DriveScan.SectorEnd := DriveScan.SectorCount - 1; … … 304 298 if Assigned(Project) then FreeAndNil(Project); 305 299 FreeAndNil(PrefixMultiplier); 300 FreeAndNil(DriveList); 306 301 end; 307 302 … … 394 389 procedure TFormMain.SaveConfig; 395 390 begin 396 XMLConfig1.SetValue('DriveName', EditDrive.Text);391 XMLConfig1.SetValue('DriveName', TDriveInfo(DriveList[ComboBoxDrive.ItemIndex]).Model); 397 392 XMLConfig1.SetValue('LastProjectFileName', LastProjectFileName); 398 393 end; … … 400 395 procedure TFormMain.LoadConfig; 401 396 begin 402 EditDrive.Text := XMLConfig1.GetValue('DriveName', DefaultDriveName);397 ComboBoxDrive.ItemIndex := DriveList.IndexOf(DriveList.FindByModel(XMLConfig1.GetValue('DriveName', ''))); 403 398 LastProjectFileName := XMLConfig1.GetValue('LastProjectFileName', ''); 404 399 end; … … 419 414 end; 420 415 421 procedure TFormMain.CheckDrive;422 begin423 DriveScan.CheckDrive;424 Project.SectorCount := DriveScan.SectorCount;425 end;426 427 416 procedure TFormMain.ProjectOpen(FileName: string); 428 417 begin … … 445 434 446 435 procedure TFormMain.Detect; 447 begin 448 436 var 437 I: Integer; 438 begin 439 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') + ')'; 449 447 end; 450 448 -
trunk/Packages/Common/UCommon.pas
r4 r12 65 65 procedure FreeThenNil(var Obj); 66 66 function RemoveQuotes(Text: string): string; 67 function LoadFileToStr(const FileName: TFileName): AnsiString; 67 68 68 69 … … 448 449 end; 449 450 451 function LoadFileToStr(const FileName: TFileName): AnsiString; 452 var 453 FileStream: TFileStream; 454 Read: Integer; 455 begin 456 Result := ''; 457 FileStream := TFileStream.Create(FileName, fmOpenRead); 458 try 459 if FileStream.Size > 0 then begin 460 SetLength(Result, FileStream.Size); 461 Read := FileStream.Read(Pointer(Result)^, FileStream.Size); 462 SetLength(Result, Read); 463 end; 464 finally 465 FileStream.Free; 466 end; 467 end; 450 468 451 469 initialization -
trunk/UDriveScan.pas
r10 r12 49 49 SectorEnd: Integer; 50 50 function GetElapsedTime: TDateTime; 51 procedure CheckDrive;52 51 procedure Reset; 53 52 procedure Start; … … 137 136 if TimeEnd <> 0 then Result := TimeEnd - TimeStart 138 137 else Result := Now - TimeStart; 139 end;140 141 procedure TDriveScan.CheckDrive;142 var143 F: TFileStream;144 begin145 if FileExists(DriveName) then begin146 F := TFileStream.Create(DriveName, fmOpenRead);147 try148 BlockMap.SectorCount := F.Size div SectorSize;149 finally150 F.Free;151 end;152 end else BlockMap.SectorCount := 0;153 138 end; 154 139 … … 227 212 if FDriveName = AValue then Exit; 228 213 FDriveName := AValue; 229 CheckDrive;230 214 end; 231 215
Note:
See TracChangeset
for help on using the changeset viewer.