A member of Xojo team gave me the solution with Declare, but I think a FolderItem.IsPackage would be welcome.
There are many package ( . app , .rtfd and so on) which may be considered as file by our program (when we through each item of a folder).
When the Lib will be deprecated, I will have to ask again help to find news Declare instructions.
Not all declares get ever deprecated; there are still declares from earlier version of MacOS X (possibly since the first release) used these days.
Asking for a not cross-platform function may not always succeed in Xojo (look at a lot of OS features not available directly because they target a single platform).
Yes, I believe it’s true. LaunchServices knows extensions that make a folder being a bundle and registers them like other documents (e.g. upon app’s first launch/discovery).
Function IsThisAPackage(fi As FolderItem) As Boolean
Try
Dim fiInfoPlist As FolderItem = fi.Child("Contents").Child("Info.plist")
Dim t As TextInputStream
Dim tAll As String
If (fiInfoPlist <> Nil) _
And fiInfoPlist.Exists Then
Try
t = TextInputStream.Open(fiInfoPlist)
tAll = t.ReadAll(Encodings.UTF8)
Catch e As IOException
t.Close
Return False
End
t.Close
If InStr(tAll, "CFBundle") > 0 Then Return True
End If
Return False
Catch
Return False
End
End Function
If a folder is a document bundle, it may not contain a “Contents” folder at all.
Only its parent application would define the folder’s extension as a bundle, but your code wouldn’t catch this.
Mac is minority here, if such need were used in more OS’s, like Android, or Windows, or Linux, it would be eligible. In some other frameworks, it would be isolated on some platform specific set of functions, like a Mac.FileUtils.*, and the same would occur for others, like Windows.FileUtils.*. This way the “core” crossplatform classes would not include platform specific things, but could be extended… when such extensions were included.