ADD: TDarwinApplicationUtil.hasFullDiskAccess() on macOS

This commit is contained in:
rich2014 2026-06-02 11:56:03 +08:00
commit 05c1e0e6bb

View file

@ -7,6 +7,7 @@ interface
uses
Classes, SysUtils, Menus, uLng,
BaseUnix,
MacOSAll, CocoaAll,
CocoaPrivate, CocoaApplication, CocoaEvent, CocoaThemes, CocoaMenus,
CocoaUtils, CocoaConst, Cocoa_Extra,
@ -54,6 +55,7 @@ type
class procedure openWithDefaultApp( const filePath: String );
class procedure performService( const serviceName: String );
class procedure openSystemSecurityPreferences_PrivacyAllFiles;
class function hasFullDiskAccess: Boolean;
public
class procedure installFNKeyTap;
class procedure uninstallFNKeyTap;
@ -264,6 +266,21 @@ begin
NSWorkspace.sharedWorkspace.openURL( url );
end;
class function TDarwinApplicationUtil.hasFullDiskAccess: Boolean;
const
testFile = '/Library/Application Support/com.apple.TCC/TCC.db';
var
fd: cInt;
begin
fd:= fpopen( pchar(testFile), O_RDONLY );
if fd = -1 then begin
Result:= False;
end else begin
fpclose( fd );
Result:= True;
end;
end;
procedure TDarwinServiceMenuManager.attachSystemMenu(Sender: TObject);
begin
self.attachServicesMenu( Sender );