mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: Show system (root) drive under macOS (fixes #1640)
This commit is contained in:
parent
fa88664159
commit
fcca7ac789
2 changed files with 42 additions and 1 deletions
|
|
@ -1330,7 +1330,7 @@ begin
|
|||
);
|
||||
|
||||
// only add known drive types and skip root directory
|
||||
if (dtype = dtUnknown) or (fs.mountpoint = PathDelim) then
|
||||
if (dtype = dtUnknown) {$IFNDEF DARWIN}or (fs.mountpoint = PathDelim){$ENDIF} then
|
||||
Continue;
|
||||
|
||||
New(drive);
|
||||
|
|
@ -1350,6 +1350,13 @@ 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 }
|
||||
end;
|
||||
{$ELSEIF DEFINED(HAIKU)}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ unit uMyDarwin;
|
|||
|
||||
{$mode delphi}
|
||||
{$modeswitch objectivec1}
|
||||
{$linkframework DiskArbitration}
|
||||
|
||||
interface
|
||||
|
||||
|
|
@ -58,6 +59,8 @@ function NSGetFolderPath(Folder: NSSearchPathDirectory): String;
|
|||
function GetFileDescription(const FileName: String): String;
|
||||
function MountNetworkDrive(const serverAddress: String): Boolean;
|
||||
|
||||
function GetVolumeName(const Device: String): String;
|
||||
|
||||
function unmountAndEject(const path: String): Boolean;
|
||||
|
||||
procedure openNewInstance();
|
||||
|
|
@ -524,6 +527,37 @@ begin
|
|||
CFRelease(FileNameRef);
|
||||
end;
|
||||
|
||||
function GetVolumeName(const Device: String): String;
|
||||
var
|
||||
ADisk: DADiskRef;
|
||||
AName: CFStringRef;
|
||||
ASession: DASessionRef;
|
||||
ADescription: CFDictionaryRef;
|
||||
begin
|
||||
Result:= EmptyStr;
|
||||
ASession:= DASessionCreate(kCFAllocatorDefault);
|
||||
if Assigned(ASession) then
|
||||
begin
|
||||
ADisk:= DADiskCreateFromBSDName(kCFAllocatorDefault, ASession, PAnsiChar(Device));
|
||||
if Assigned(ADisk) then
|
||||
begin
|
||||
ADescription:= DADiskCopyDescription(ADisk);
|
||||
if Assigned(ADescription) then
|
||||
begin
|
||||
AName:= CFDictionaryGetValue(ADescription, kDADiskDescriptionVolumeNameKey);
|
||||
if (AName = nil) then AName:= CFDictionaryGetValue(ADescription, kDADiskDescriptionMediaNameKey);
|
||||
if Assigned(AName) then
|
||||
begin
|
||||
Result:= CFStringToStr(AName);
|
||||
end;
|
||||
CFRelease(ADescription);
|
||||
end;
|
||||
CFRelease(ADisk);
|
||||
end;
|
||||
CFRelease(ASession);
|
||||
end;
|
||||
end;
|
||||
|
||||
function unmountAndEject(const path: String): Boolean;
|
||||
begin
|
||||
Result:= NSWorkspace.sharedWorkspace.unmountAndEjectDeviceAtPath( StringToNSString(path) );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue