Changeset 13 for trunk/UPhysDrive.pas
- Timestamp:
- Apr 2, 2016, 1:06:34 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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);
Note:
See TracChangeset
for help on using the changeset viewer.