When I set a FolderItem to a folder within my ApplicationData folder, f.Count is correct and > 0. When I run the same code on a folder outside my ApplicationData folder (eg Documents), it always returns zero (I have the same results with FileListMBS.Count).
I assumed this was an AppWrapper capabilities issue, so I gave myself access to the Documents folder, but the result is still zero.
How can I get the f.Count outside of the ApplicationData folder in a signed app?
Which version of macOS and which version of Xojo do you use?
On Crapolina and higher you should see the wonderful “do you really want to” dialogs before you have access to a folder. The user needs to select the folder.
I have a list of NativePath pathnames stored in a database. As an example NativePathToFind is a folder (/Users/davidcox/Documents/CubeiTz Decrypted/0000033439).
If I remove the AppWrapper Script I can access the f.Count in this Documents subfolder, so I assume it is a signing and permissions issue. My only question is how can I gain access to ‘see’ these files?!
Here is my code:
…
Var NativePathToFind As String = AllNativePaths(tempInt)
f = New FolderItem(NativePathToFind, FolderItem.PathModes.Native)
'f = SpecialFolder.ApplicationData 'this works OK
Var AllFiles() As FolderItem
If f <> Nil And f.Exists Then 'f.Count = 0 here
If f.IsFolder Then
Var tempFileListMBS As New FileListMBS(f) 'tempFileListMBS.Count = 0 here
Var NumFiles As Integer = tempFileListMBS.Count - 1
For tempInt2 As Integer = 0 To NumFiles 'this never loops as NumFiles = -1
Var g As FolderItem = tempFileListMBS.TrueItem(tempInt2)
If g <> Nil And g.Exists And Not g.IsFolder Then
AllFiles.Add(g)
End If
Next
Else
AllFiles.Add(f)
End If
If you know the list of places that Apple is denying and the app needs, you are right. That recipe is just the easy “let’s try to make that trusted crashing app to work”.
Yes, this seems to be the source of my problem. Unsandboxed it shows the files within a folder, but sandboxed with AppWrapper I can no longer scan for files.
I don’t have the luxury of getting users to select the folder (as I do elsewhere) as I am checking through a list of FolderItems previously chosen by the user (eg in another session). I am happy that it only checks within the Documents folder, but how do I get macOS/AppWrapper to allow me to scan for files within Documents?
I have tried all day to get either SSFolderitem or CFBookmarkMBS to give me Documents folder access in a sandboxed application and have failed.
I can get a BookMark from a FolderItem and resolve a BookMark to a FolderItem, but have failed to have them give me permission to access the file/folder in a sandboxed application.