Full Disk Access add or not?

Hi,
How to test if the Xojo app has been added or not, to “Full Disk Access” in System Preferences, by the user?

I try to access the one of the folders in Mail.

Get the main directory for each version of Mail:

Protected Function getMainDirectory(theAccountDirectories() as FolderItem) As FolderItem
  
  'get the location of VX folder in Library/Mail
  dim theResult as FolderItem
  
  if SystemInformationMBS.isMonterey then
    theResult = new FolderItem(SpecialFolder.UserLibrary.ShellPath + "/Mail/V9", folderItem.PathModes.Shell)
 'and so on
  end if
  
  Return theResult
  
End Function

And then I check if there are files in the directory:

Private Function CheckFullDiskAccess() As Boolean

'if we are on mojave and archive from mail check we have full disk access

if CarbonModule.SystemVersionAsInt < 101400 then Return True 'not mojave

if MainMailFolder.Count >= 1 then
dim FirstFolder as FolderItem = MainMailFolder.ChildAt(0)

if FirstFolder = Nil then
  Return False
else
  Return True
end if

end if

End Function

Thank you very much.

Hi @Beatrix_Willius,

I have any errors in my method named “CheckFullDiskAccess” :

1- This item does not exist “CarbonModule”
if CarbonModule.SystemVersionAsInt < 101400 then Return True 'not Mojave

2- Type “Int32” has no member named “SystemVersionAsInt”
if CarbonModule.SystemVersionAsInt < 101400 then Return True 'not Mojave

3- This item does not exist : if “MainMailFolder”.Count >= 1 then…

Thanks for help,

Use

If not SystemInformationMBS.isMojave then return True

instead.

If System.Version >= "10.14.0" Then

https://documentation.xojo.com/api/os/system.html#system-version

Thank you.
What exactly is MainMailFolder (FolderItem ?)
Is this the result of getMainDirectory function?

if MainMailFolder.Count >= 1 then
  dim FirstFolder as FolderItem = MainMailFolder.ChildAt(0)

Here is my getMainDirectory function:

Protected Function getMainDirectory(theAccountDirectories() as FolderItem) As FolderItem
  
  'get the location of VX folder in Library/Mail
  
  if theAccountDirectories.LastIndex = -1 then
    Return Nil
  end if
  
  dim theResult as FolderItem  
  if SystemInformationMBS.isMonterey then
    theResult = new FolderItem(SpecialFolder.UserLibrary.ShellPath + "/Mail/V9", folderItem.PathModes.Shell)
  elseif SystemInformationMBS.isBigSur then
    theResult = new FolderItem(SpecialFolder.UserLibrary.ShellPath + "/Mail/V8", folderItem.PathModes.Shell)
  elseif SystemInformationMBS.isCatalina then
    theResult = new FolderItem(SpecialFolder.UserLibrary.ShellPath + "/Mail/V7", folderItem.PathModes.Shell)
  ElseIf SystemInformationMBS.isMojave then
    theResult = new FolderItem(SpecialFolder.UserLibrary.ShellPath + "/Mail/V6", folderItem.PathModes.Shell)
  elseif SystemInformationMBS.isHighSierra then
    theResult = new FolderItem(SpecialFolder.UserLibrary.ShellPath + "/Mail/V5", folderItem.PathModes.Shell)
  end if
  
  Return theResult

End Function

Thanks. And for “MainMailFolder”, how is it declared ?