63000 - Add a FolderItem.IsPackage instruction

Feedback Case Number: 63000

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).

As I understand it, the basic rule of a package is a folder with a file extension that is registered on the system.

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).

I do it this way:

	Function IsThisAPackage(fi As FolderItem) As Boolean
	    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
	        t = TextInputStream.Open(fiInfoPlist)
	        tAll = t.ReadAll(Encodings.UTF8)
	      Catch e As IOException
	        Return False
	      If InStr(tAll, "CFBundle") > 0 Then Return True
	    End If
	    Return False
	    Return False
	End Function

What’s the result of a call asking for info for an URL that does not result in a bundle?
Maybe just one call can solve this without false positives.


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.

1 Like

Add false negatives to my comment too. :smile:

How about FolderItem.isBundleMBS function in MBS Xojo Plugins?

1 Like

If one has your plugin…

But, using macOSlib one could do it this way:

Dim bundleURL As CoreFoundation.CFURL
bundleURL = CFURL.CreateFromPOSIXPath(fi.NativePath, True)
Return bundleURL.IsPackage

Wouldn’t be something like CFURLCreateWithFileSystemPath() a better current option?


But they could do better. This would just always return false on other platforms. Simple.


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.

I see a mixture of different things here, and confusion. What is it exactly that you are trying to accomplish?

A bundle is a package, but a package may not be a bundle.

This made me curious, so I searched for some info and found this great article: