Platforms to show: All Mac Windows Linux Cross-Platform

/MacCF/CFBundle example


Required plugins for this example: MBS MacCF Plugin, MBS Util Plugin, MBS Main Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCF/CFBundle example

This example is the version from Fri, 21th Nov 2019.

Project "CFBundle example.xojo_binary_project"
FileTypes
Filetype special/folder
Filetype special/application
End FileTypes
Class Window1 Inherits Window
Control ListBox1 Inherits ListBox
ControlInstance ListBox1 Inherits ListBox
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() AllBundlesWindow.Show End EventHandler
End Control
EventHandler Sub DropObject(obj As DragItem, action As Integer) #pragma unused action do if obj.FolderItemAvailable then run obj.FolderItem end if loop until not obj.NextItem End EventHandler
EventHandler Sub Open() dim f as FolderItem AcceptFileDrop "special/folder" AcceptFileDrop "special/application" f=ApplicationsFolderMBS(-32766).Child("Image Capture.app") run f End EventHandler
Sub addrow(a as string,b as string) ListBox1.AddRow a ListBox1.cell(ListBox1.LastIndex,1)=b End Sub
Sub run(f as folderItem) dim u as CFURLMBS dim d as CFDictionaryMBS dim c as CFBundleMBS ListBox1.DeleteAllRows if f<>Nil and f.Exists then u=NewCFURLMBSFile(f) if u<>nil then c=CreateBundleMBS(u) if c<>nil then d=c.GetLocalInfoDictionary if d<>Nil then d=c.GetInfoDictionary end if if d<>nil then addrow "Name: ",st(c.GetValueForInfoDictionaryKey(c.kCFBundleNameKey)) addrow "Version: ",st(c.GetValueForInfoDictionaryKey(c.kCFBundleVersionKey)) addrow "Executable: ",st(c.GetValueForInfoDictionaryKey(c.kCFBundleExecutableKey)) addrow "Identifier: ",st(c.GetValueForInfoDictionaryKey(c.kCFBundleIdentifierKey)) addrow "Info Dictionary Version: ",st(c.GetValueForInfoDictionaryKey(c.kCFBundleInfoDictionaryVersionKey)) addrow "Development Region: ",st(c.GetValueForInfoDictionaryKey(c.kCFBundleDevelopmentRegionKey)) addrow "Type: ",c.PackageMacType addrow "Creator: ",c.PackageMacCreator addrow "Resource folder: ",ur(c.ResourceDirectory) addrow "Support folder: ",ur(c.SupportFilesDirectory) addrow "Frameworks folder: ",ur(c.SharedFrameworksDirectory) addrow "Private Frameworks folder: ",ur(c.PrivateFrameworksDirectory) addrow "Plugins folder: ",ur(c.BuiltInPlugInsDirectory) else ListBox1.AddRow "No Info Dictionary" end if else ListBox1.AddRow "CreateBundleMBS failed." end if else ListBox1.AddRow "NewCFURLMBSFile failed." end if else ListBox1.AddRow "File not found!?" end if End Sub
Function st(o as cfobjectMBS) As string if o isa CFStringMBS then dim s as CFStringMBS = CFStringMBS(o) Return s.str end if End Function
Function ur(u as cfurLMBS) As string if u<>nil then Return st(u.PosixFileSystemPath) end if End Function
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu7 = ""
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
MenuItem UntitledMenu6 = ""
MenuItem UntitledMenu5 = ""
MenuItem UntitledMenu4 = ""
End MenuBar
Class App Inherits Application
End Class
Class AllBundlesWindow Inherits Window
Control List Inherits ListBox
ControlInstance List Inherits ListBox
End Control
EventHandler Sub Open() dim i,co as integer dim c as CFBundleMBS dim d as CFDictionaryMBS dim s as String dim cs as CFStringMBS dim f as FolderItem = ApplicationsFolderMBS(-32766) dim url as CFURLMBS = NewCFURLMBSFile(f) dim a as CFArrayMBS = CreateBundlesFromDirectoryMBS(url,NewCFStringMBS(".app")) if a=nil then MsgBox "no bundles found!?" else co=a.Count-1 for i=0 to co dim o as CFObjectMBS = a.Item(i) if o<>Nil and o.Type=kCFBundleMBSTypeID then // Make a CFBundle object from the CFObject c = CFBundleMBS(o) // display cs=c.Identifier if cs<>nil then s=cs.str else s="" end if List.AddRow c.PackageMacCreator+" "+c.PackageMacType List.Cell(list.LastIndex,1)=s d=c.GetInfoDictionary if d<>Nil then o=d.Value(c.kCFBundleNameKey) if o<>nil then List.cell(List.LastIndex,2)=CFStringMBS(o).str end if o=d.Value(c.kCFBundleVersionKey) if o<>nil then List.cell(List.LastIndex,3)=CFStringMBS(o).str end if end if url=c.URL if url<>nil then List.cell(List.LastIndex,4)=url.Path.str end if end if next end if End EventHandler
End Class
End Project

The items on this page are in the following plugins: MBS MacCF Plugin.


The biggest plugin in space...