Changeset 28 for trunk/UPhysDrive.pas
- Timestamp:
- Apr 7, 2016, 7:01:24 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UPhysDrive.pas
r21 r28 6 6 7 7 uses 8 Classes, SysUtils, Contnrs, UFindFile, UCommon 8 Classes, SysUtils, Contnrs, UFindFile, UCommon, Math 9 9 {$IFDEF Windows},ActiveX,ComObj,Variants 10 10 {$ENDIF}; … … 16 16 17 17 TDriveInfo = class 18 private 19 FSectorSize: Integer; 20 FSectorCount: Int64; 21 FSize: Int64; 22 function GetSectorCount: Int64; 23 procedure SetSectorSize(AValue: Integer); 24 procedure SetSize(AValue: Int64); 25 public 18 26 Kind: TDriveKind; 19 27 Model: string; 20 Size: Int64;21 SectorCount: Int64;22 SectorSize: Integer;23 28 Path: string; 29 constructor Create; 24 30 procedure Assign(Source: TDriveInfo); 31 property SectorSize: Integer read FSectorSize write SetSectorSize; 32 property SectorCount: Int64 read GetSectorCount; 33 property Size: Int64 read FSize write SetSize; 25 34 end; 26 35 … … 42 51 UPrefixMultiplier; 43 52 53 resourcestring 54 SMinSectorSize = 'Minimum sector size is 1'; 55 44 56 { TDriveInfo } 57 58 procedure TDriveInfo.SetSectorSize(AValue: Integer); 59 begin 60 if FSectorSize = AValue then Exit; 61 if Avalue < 1 then 62 raise Exception.Create(SMinSectorSize); 63 FSectorSize := AValue; 64 FSectorCount := Ceil(FSize / FSectorSize); 65 end; 66 67 function TDriveInfo.GetSectorCount: Int64; 68 begin 69 Result := Ceil(FSize / FSectorSize); 70 end; 71 72 procedure TDriveInfo.SetSize(AValue: Int64); 73 begin 74 if FSize=AValue then Exit; 75 FSize:=AValue; 76 end; 77 78 constructor TDriveInfo.Create; 79 begin 80 FSectorSize := 1; 81 end; 45 82 46 83 procedure TDriveInfo.Assign(Source: TDriveInfo); … … 49 86 Model := Source.Model; 50 87 Size := Source.Size; 51 SectorCount := Source.SectorCount;88 FSectorCount := Source.FSectorCount; 52 89 SectorSize := Source.SectorSize; 53 90 end; … … 108 145 NewDriveInfo.Model := Trim(LoadFileToStr(List[I] + '/device/model')); 109 146 NewDriveInfo.SectorSize := StrToInt(Trim(LoadFileToStr(List[I] + '/queue/physical_block_size'))); 110 NewDriveInfo.SectorCount := StrToInt(Trim(LoadFileToStr(List[I] + '/size'))) * 512 div NewDriveInfo.SectorSize; 111 NewDriveInfo.Size := NewDriveInfo.SectorCount * NewDriveInfo.SectorSize; 147 NewDriveInfo.Size := StrToInt(Trim(LoadFileToStr(List[I] + '/size'))) * 512; 112 148 NewDriveInfo.Path := '/dev/' + ExtractFileName(List[I]); 113 149 Add(NewDriveInfo); … … 123 159 NewDriveInfo.Model := 'File'; 124 160 NewDriveInfo.SectorSize := 4096; 125 NewDriveInfo.SectorCount := 0;126 161 NewDriveInfo.Size := 0; 127 162 NewDriveInfo.Path := '';
Note:
See TracChangeset
for help on using the changeset viewer.