Changeset 22 for trunk/UDriveScan.pas
- Timestamp:
- Apr 4, 2016, 12:24:37 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UDriveScan.pas
r21 r22 6 6 7 7 uses 8 Classes, SysUtils, Syncobjs, UBlockMap, Forms, DOM, 9 UXMLUtils, Contnrs , UPhysDrive;8 Classes, SysUtils, Syncobjs, UBlockMap, Forms, DOM, UConfig, 9 UXMLUtils, Contnrs; 10 10 11 11 type … … 36 36 WritePattern: Byte; 37 37 procedure LoadFromDriveInfo(DriveInfo: TDriveInfo); 38 end; 39 40 { TTestStream } 41 42 TTestStream = class(TStream) 43 public 44 function Read(var Buffer; Count: Longint): Longint; override; 45 function Write(const Buffer; Count: Longint): Longint; override; 46 function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override; 38 47 end; 39 48 … … 68 77 SectorStart: Integer; 69 78 SectorEnd: Integer; 79 function GetName: string; 70 80 function GetElapsedTime: TDateTime; 71 81 procedure Reset; … … 106 116 end; 107 117 118 { TTestStream } 119 120 function TTestStream.Read(var Buffer; Count: Longint): Longint; 121 begin 122 // if Random < 0.00001 then Result := 0 123 // else 124 Result := Count; 125 end; 126 127 function TTestStream.Write(const Buffer; Count: Longint): Longint; 128 begin 129 end; 130 131 function TTestStream.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; 132 begin 133 end; 134 108 135 { TDriveScanList } 109 136 … … 206 233 procedure TDriveScan.Run; 207 234 var 208 F: T FileStream;235 F: TStream; 209 236 RealSize: Integer; 210 237 Buffer: array of Byte; … … 213 240 Lock.Acquire; 214 241 Terminated := False; 215 if Mode = rmRead then F := TFileStream.Create(DriveName, fmOpenRead) 216 else if Mode = rmWrite then F := TFileStream.Create(DriveName, fmOpenReadWrite); 242 if ConfigTest then F := TTestStream.Create 243 else begin 244 if Mode = rmRead then F := TFileStream.Create(DriveName, fmOpenRead) 245 else if Mode = rmWrite then F := TFileStream.Create(DriveName, fmOpenReadWrite); 246 end; 217 247 try 218 248 SetLength(Buffer, SectorSize); … … 264 294 end; 265 295 296 function TDriveScan.GetName: string; 297 begin 298 if Mode = rmRead then Result := 'Read' 299 else if Mode = rmWrite then Result := 'Write pattern $' + IntToHex(WritePattern, 2) 300 else Result := ''; 301 end; 302 266 303 procedure TDriveScan.Stop; 267 304 begin … … 305 342 with Node do begin 306 343 WriteInteger(Node, 'DamagedBlockCount', DamagedBlockCount); 344 WriteInteger(Node, 'RunMode', Integer(Mode)); 307 345 WriteInteger(Node, 'WritePattern', WritePattern); 308 346 WriteString(Node, 'DriveName', DriveName); … … 327 365 with Node do begin 328 366 DamagedBlockCount := ReadInteger(Node, 'DamagedBlockCount', 0); 367 Mode := TRunMode(ReadInteger(Node, 'RunMode', 0)); 329 368 WritePattern := ReadInteger(Node, 'WritePattern', 0); 330 369 DriveName := ReadString(Node, 'DriveName', '');
Note:
See TracChangeset
for help on using the changeset viewer.