Changeset 22 for trunk/UDriveScan.pas


Ignore:
Timestamp:
Apr 4, 2016, 12:24:37 AM (9 years ago)
Author:
chronos
Message:
  • Modified: Show name in operation list.
  • Fixed: Store scan run mode in project file.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UDriveScan.pas

    r21 r22  
    66
    77uses
    8   Classes, SysUtils, Syncobjs, UBlockMap, Forms, DOM,
    9   UXMLUtils, Contnrs, UPhysDrive;
     8  Classes, SysUtils, Syncobjs, UBlockMap, Forms, DOM, UConfig,
     9  UXMLUtils, Contnrs;
    1010
    1111type
     
    3636    WritePattern: Byte;
    3737    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;
    3847  end;
    3948
     
    6877    SectorStart: Integer;
    6978    SectorEnd: Integer;
     79    function GetName: string;
    7080    function GetElapsedTime: TDateTime;
    7181    procedure Reset;
     
    106116end;
    107117
     118{ TTestStream }
     119
     120function TTestStream.Read(var Buffer; Count: Longint): Longint;
     121begin
     122//  if Random < 0.00001 then Result := 0
     123//   else
     124     Result := Count;
     125end;
     126
     127function TTestStream.Write(const Buffer; Count: Longint): Longint;
     128begin
     129end;
     130
     131function TTestStream.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64;
     132begin
     133end;
     134
    108135{ TDriveScanList }
    109136
     
    206233procedure TDriveScan.Run;
    207234var
    208   F: TFileStream;
     235  F: TStream;
    209236  RealSize: Integer;
    210237  Buffer: array of Byte;
     
    213240    Lock.Acquire;
    214241    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;
    217247    try
    218248      SetLength(Buffer, SectorSize);
     
    264294end;
    265295
     296function TDriveScan.GetName: string;
     297begin
     298  if Mode = rmRead then Result := 'Read'
     299  else if Mode = rmWrite then Result := 'Write pattern $' + IntToHex(WritePattern, 2)
     300  else Result := '';
     301end;
     302
    266303procedure TDriveScan.Stop;
    267304begin
     
    305342  with Node do begin
    306343    WriteInteger(Node, 'DamagedBlockCount', DamagedBlockCount);
     344    WriteInteger(Node, 'RunMode', Integer(Mode));
    307345    WriteInteger(Node, 'WritePattern', WritePattern);
    308346    WriteString(Node, 'DriveName', DriveName);
     
    327365  with Node do begin
    328366    DamagedBlockCount := ReadInteger(Node, 'DamagedBlockCount', 0);
     367    Mode := TRunMode(ReadInteger(Node, 'RunMode', 0));
    329368    WritePattern := ReadInteger(Node, 'WritePattern', 0);
    330369    DriveName := ReadString(Node, 'DriveName', '');
Note: See TracChangeset for help on using the changeset viewer.