UPD: improve support for root '/' in TDriveWatcher.GetDrivesList() on macOS

This commit is contained in:
rich2014 2025-11-08 22:59:07 +08:00
commit 417989d64b
2 changed files with 13 additions and 11 deletions

View file

@ -1409,13 +1409,6 @@ begin
IsMounted := true;
AutoMount := true;
end; { with }
{$IF DEFINED(DARWIN)}
if (fs.mountpoint = PathDelim) then
begin
Drive^.DisplayName:= GetVolumeName(fs.mntfromname);
if Length(Drive^.DisplayName) = 0 then Drive^.DisplayName:= 'System';
end;
{$ENDIF}
end; { for }
{$IF DEFINED(DARWIN)}
FreeAndNil( darwinVolumns );

View file

@ -210,6 +210,10 @@ var
groupUUID: NSString;
dataDeviceID: NSString;
begin
Result:= fs^.mountpoint;
if Result = PathDelim then
Exit;
dataFs:= nil;
groupUUID:= self.getGroupUUIDByDeviceID( StrToNSString(deviceID) );
if groupUUID <> nil then begin
@ -217,15 +221,20 @@ begin
if dataDeviceID <> nil then
dataFs:= self.getStatfsByDeviceID( dataDeviceID );
end;
if dataFs = nil then
dataFS:= fs;
Result:= dataFS^.mountpoint;
if Assigned(dataFs) then
Result:= dataFS^.mountpoint;
end;
function TDarwinIOVolumns.getDisplayNameByDeviceID(const deviceID: String;
fs: PDarwinStatfs): String;
begin
Result:= fs^.mountpoint;
if fs^.mountpoint = PathDelim then begin
Result:= GetVolumeName( fs^.mntfromname );
if Result = EmptyStr then
Result:= 'System';
end else begin
Result:= fs^.mountpoint;
end;
end;
initialization