CFBundle.pas 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. { CFBundle.h
  2. Copyright (c) 1999-2013, Apple Inc. All rights reserved.
  3. }
  4. {
  5. Modified for use with Free Pascal
  6. Version 308
  7. Please report any bugs to <[email protected]>
  8. }
  9. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  10. {$mode macpas}
  11. {$modeswitch cblocks}
  12. {$packenum 1}
  13. {$macro on}
  14. {$inline on}
  15. {$calling mwpascal}
  16. unit CFBundle;
  17. interface
  18. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  19. {$setc GAP_INTERFACES_VERSION := $0308}
  20. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  21. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  22. {$endc}
  23. {$ifc defined CPUPOWERPC and defined CPUI386}
  24. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  25. {$endc}
  26. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  27. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  28. {$endc}
  29. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  30. {$setc __ppc__ := 1}
  31. {$elsec}
  32. {$setc __ppc__ := 0}
  33. {$endc}
  34. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  35. {$setc __ppc64__ := 1}
  36. {$elsec}
  37. {$setc __ppc64__ := 0}
  38. {$endc}
  39. {$ifc not defined __i386__ and defined CPUI386}
  40. {$setc __i386__ := 1}
  41. {$elsec}
  42. {$setc __i386__ := 0}
  43. {$endc}
  44. {$ifc not defined __x86_64__ and defined CPUX86_64}
  45. {$setc __x86_64__ := 1}
  46. {$elsec}
  47. {$setc __x86_64__ := 0}
  48. {$endc}
  49. {$ifc not defined __arm__ and defined CPUARM}
  50. {$setc __arm__ := 1}
  51. {$elsec}
  52. {$setc __arm__ := 0}
  53. {$endc}
  54. {$ifc not defined __arm64__ and defined CPUAARCH64}
  55. {$setc __arm64__ := 1}
  56. {$elsec}
  57. {$setc __arm64__ := 0}
  58. {$endc}
  59. {$ifc defined cpu64}
  60. {$setc __LP64__ := 1}
  61. {$elsec}
  62. {$setc __LP64__ := 0}
  63. {$endc}
  64. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  65. {$error Conflicting definitions for __ppc__ and __i386__}
  66. {$endc}
  67. {$ifc defined __ppc__ and __ppc__}
  68. {$setc TARGET_CPU_PPC := TRUE}
  69. {$setc TARGET_CPU_PPC64 := FALSE}
  70. {$setc TARGET_CPU_X86 := FALSE}
  71. {$setc TARGET_CPU_X86_64 := FALSE}
  72. {$setc TARGET_CPU_ARM := FALSE}
  73. {$setc TARGET_CPU_ARM64 := FALSE}
  74. {$setc TARGET_OS_MAC := TRUE}
  75. {$setc TARGET_OS_IPHONE := FALSE}
  76. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  77. {$setc TARGET_OS_EMBEDDED := FALSE}
  78. {$elifc defined __ppc64__ and __ppc64__}
  79. {$setc TARGET_CPU_PPC := FALSE}
  80. {$setc TARGET_CPU_PPC64 := TRUE}
  81. {$setc TARGET_CPU_X86 := FALSE}
  82. {$setc TARGET_CPU_X86_64 := FALSE}
  83. {$setc TARGET_CPU_ARM := FALSE}
  84. {$setc TARGET_CPU_ARM64 := FALSE}
  85. {$setc TARGET_OS_MAC := TRUE}
  86. {$setc TARGET_OS_IPHONE := FALSE}
  87. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  88. {$setc TARGET_OS_EMBEDDED := FALSE}
  89. {$elifc defined __i386__ and __i386__}
  90. {$setc TARGET_CPU_PPC := FALSE}
  91. {$setc TARGET_CPU_PPC64 := FALSE}
  92. {$setc TARGET_CPU_X86 := TRUE}
  93. {$setc TARGET_CPU_X86_64 := FALSE}
  94. {$setc TARGET_CPU_ARM := FALSE}
  95. {$setc TARGET_CPU_ARM64 := FALSE}
  96. {$ifc defined(iphonesim)}
  97. {$setc TARGET_OS_MAC := FALSE}
  98. {$setc TARGET_OS_IPHONE := TRUE}
  99. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  100. {$elsec}
  101. {$setc TARGET_OS_MAC := TRUE}
  102. {$setc TARGET_OS_IPHONE := FALSE}
  103. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  104. {$endc}
  105. {$setc TARGET_OS_EMBEDDED := FALSE}
  106. {$elifc defined __x86_64__ and __x86_64__}
  107. {$setc TARGET_CPU_PPC := FALSE}
  108. {$setc TARGET_CPU_PPC64 := FALSE}
  109. {$setc TARGET_CPU_X86 := FALSE}
  110. {$setc TARGET_CPU_X86_64 := TRUE}
  111. {$setc TARGET_CPU_ARM := FALSE}
  112. {$setc TARGET_CPU_ARM64 := FALSE}
  113. {$ifc defined(iphonesim)}
  114. {$setc TARGET_OS_MAC := FALSE}
  115. {$setc TARGET_OS_IPHONE := TRUE}
  116. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  117. {$elsec}
  118. {$setc TARGET_OS_MAC := TRUE}
  119. {$setc TARGET_OS_IPHONE := FALSE}
  120. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  121. {$endc}
  122. {$setc TARGET_OS_EMBEDDED := FALSE}
  123. {$elifc defined __arm__ and __arm__}
  124. {$setc TARGET_CPU_PPC := FALSE}
  125. {$setc TARGET_CPU_PPC64 := FALSE}
  126. {$setc TARGET_CPU_X86 := FALSE}
  127. {$setc TARGET_CPU_X86_64 := FALSE}
  128. {$setc TARGET_CPU_ARM := TRUE}
  129. {$setc TARGET_CPU_ARM64 := FALSE}
  130. { will require compiler define when/if other Apple devices with ARM cpus ship }
  131. {$setc TARGET_OS_MAC := FALSE}
  132. {$setc TARGET_OS_IPHONE := TRUE}
  133. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  134. {$setc TARGET_OS_EMBEDDED := TRUE}
  135. {$elifc defined __arm64__ and __arm64__}
  136. {$setc TARGET_CPU_PPC := FALSE}
  137. {$setc TARGET_CPU_PPC64 := FALSE}
  138. {$setc TARGET_CPU_X86 := FALSE}
  139. {$setc TARGET_CPU_X86_64 := FALSE}
  140. {$setc TARGET_CPU_ARM := FALSE}
  141. {$setc TARGET_CPU_ARM64 := TRUE}
  142. { will require compiler define when/if other Apple devices with ARM cpus ship }
  143. {$setc TARGET_OS_MAC := FALSE}
  144. {$setc TARGET_OS_IPHONE := TRUE}
  145. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  146. {$setc TARGET_OS_EMBEDDED := TRUE}
  147. {$elsec}
  148. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
  149. {$endc}
  150. {$ifc defined __LP64__ and __LP64__ }
  151. {$setc TARGET_CPU_64 := TRUE}
  152. {$elsec}
  153. {$setc TARGET_CPU_64 := FALSE}
  154. {$endc}
  155. {$ifc defined FPC_BIG_ENDIAN}
  156. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  157. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  158. {$elifc defined FPC_LITTLE_ENDIAN}
  159. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  160. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  161. {$elsec}
  162. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  163. {$endc}
  164. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  165. {$setc CALL_NOT_IN_CARBON := FALSE}
  166. {$setc OLDROUTINENAMES := FALSE}
  167. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  168. {$setc OPAQUE_UPP_TYPES := TRUE}
  169. {$setc OTCARBONAPPLICATION := TRUE}
  170. {$setc OTKERNEL := FALSE}
  171. {$setc PM_USE_SESSION_APIS := TRUE}
  172. {$setc TARGET_API_MAC_CARBON := TRUE}
  173. {$setc TARGET_API_MAC_OS8 := FALSE}
  174. {$setc TARGET_API_MAC_OSX := TRUE}
  175. {$setc TARGET_CARBON := TRUE}
  176. {$setc TARGET_CPU_68K := FALSE}
  177. {$setc TARGET_CPU_MIPS := FALSE}
  178. {$setc TARGET_CPU_SPARC := FALSE}
  179. {$setc TARGET_OS_UNIX := FALSE}
  180. {$setc TARGET_OS_WIN32 := FALSE}
  181. {$setc TARGET_RT_MAC_68881 := FALSE}
  182. {$setc TARGET_RT_MAC_CFM := FALSE}
  183. {$setc TARGET_RT_MAC_MACHO := TRUE}
  184. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  185. {$setc TYPE_BOOL := FALSE}
  186. {$setc TYPE_EXTENDED := FALSE}
  187. {$setc TYPE_LONGLONG := TRUE}
  188. uses MacTypes,CFBase,CFArray,CFDictionary,CFError,CFString,CFURL;
  189. {$endc} {not MACOSALLINCLUDE}
  190. {$ALIGN POWER}
  191. type
  192. CFBundleRef = ^__CFBundle; { an opaque type }
  193. __CFBundle = record end;
  194. CFBundleRefPtr = ^CFBundleRef;
  195. CFPlugInRef = ^__CFBundle; { an opaque type }
  196. CFPlugInRefPtr = ^CFPlugInRef;
  197. { ===================== Standard Info.plist keys ===================== }
  198. var kCFBundleInfoDictionaryVersionKey: CFStringRef; external name '_kCFBundleInfoDictionaryVersionKey'; (* attribute const *)
  199. { The version of the Info.plist format }
  200. var kCFBundleExecutableKey: CFStringRef; external name '_kCFBundleExecutableKey'; (* attribute const *)
  201. { The name of the executable in this bundle, if any }
  202. var kCFBundleIdentifierKey: CFStringRef; external name '_kCFBundleIdentifierKey'; (* attribute const *)
  203. { The bundle identifier (for CFBundleGetBundleWithIdentifier()) }
  204. var kCFBundleVersionKey: CFStringRef; external name '_kCFBundleVersionKey'; (* attribute const *)
  205. { The version number of the bundle. For Mac OS 9 style version numbers (for example "2.5.3d5"), }
  206. { clients can use CFBundleGetVersionNumber() instead of accessing this key directly since that }
  207. { function will properly convert the version string into its compact integer representation. }
  208. var kCFBundleDevelopmentRegionKey: CFStringRef; external name '_kCFBundleDevelopmentRegionKey'; (* attribute const *)
  209. { The name of the development language of the bundle. }
  210. var kCFBundleNameKey: CFStringRef; external name '_kCFBundleNameKey'; (* attribute const *)
  211. { The human-readable name of the bundle. This key is often found in the InfoPlist.strings since it is usually localized. }
  212. {#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED}
  213. var kCFBundleLocalizationsKey: CFStringRef; external name '_kCFBundleLocalizationsKey'; (* attribute const *)
  214. { Allows an unbundled application that handles localization itself to specify which localizations it has available. }
  215. {#endif}
  216. { ===================== Finding Bundles ===================== }
  217. function CFBundleGetMainBundle: CFBundleRef; external name '_CFBundleGetMainBundle';
  218. function CFBundleGetBundleWithIdentifier( bundleID: CFStringRef ): CFBundleRef; external name '_CFBundleGetBundleWithIdentifier';
  219. { A bundle can name itself by providing a key in the info dictionary. }
  220. { This facility is meant to allow bundle-writers to get hold of their }
  221. { bundle from their code without having to know where it was on the disk. }
  222. { This is meant to be a replacement mechanism for +bundleForClass: users. }
  223. { Note that this does not search for bundles on the disk; it will locate }
  224. { only bundles already loaded or otherwise known to the current process. }
  225. function CFBundleGetAllBundles: CFArrayRef; external name '_CFBundleGetAllBundles';
  226. { This is potentially expensive, and not thread-safe. Use with care. }
  227. { Best used for debuggging or other diagnostic purposes. }
  228. { ===================== Creating Bundles ===================== }
  229. function CFBundleGetTypeID: CFTypeID; external name '_CFBundleGetTypeID';
  230. function CFBundleCreate( allocator: CFAllocatorRef; bundleURL: CFURLRef ): CFBundleRef; external name '_CFBundleCreate';
  231. { Might return an existing instance with the ref-count bumped. }
  232. function CFBundleCreateBundlesFromDirectory( allocator: CFAllocatorRef; directoryURL: CFURLRef; bundleType: CFStringRef ): CFArrayRef; external name '_CFBundleCreateBundlesFromDirectory';
  233. { Create instances for all bundles in the given directory matching the given type }
  234. { (or all of them if bundleType is NULL). Instances are created using CFBundleCreate() and are not released. }
  235. { ==================== Basic Bundle Info ==================== }
  236. function CFBundleCopyBundleURL( bundle: CFBundleRef ): CFURLRef; external name '_CFBundleCopyBundleURL';
  237. function CFBundleGetValueForInfoDictionaryKey( bundle: CFBundleRef; key: CFStringRef ): CFTypeRef; external name '_CFBundleGetValueForInfoDictionaryKey';
  238. { Returns a localized value if available, otherwise the global value. }
  239. { This is the recommended function for examining the info dictionary. }
  240. function CFBundleGetInfoDictionary( bundle: CFBundleRef ): CFDictionaryRef; external name '_CFBundleGetInfoDictionary';
  241. { This is the global info dictionary. Note that CFBundle may add }
  242. { extra keys to the dictionary for its own use. }
  243. function CFBundleGetLocalInfoDictionary( bundle: CFBundleRef ): CFDictionaryRef; external name '_CFBundleGetLocalInfoDictionary';
  244. { This is the localized info dictionary. }
  245. procedure CFBundleGetPackageInfo( bundle: CFBundleRef; var packageType: OSType; var packageCreator: OSType ); external name '_CFBundleGetPackageInfo';
  246. function CFBundleGetIdentifier( bundle: CFBundleRef ): CFStringRef; external name '_CFBundleGetIdentifier';
  247. function CFBundleGetVersionNumber( bundle: CFBundleRef ): UInt32; external name '_CFBundleGetVersionNumber';
  248. function CFBundleGetDevelopmentRegion( bundle: CFBundleRef ): CFStringRef; external name '_CFBundleGetDevelopmentRegion';
  249. function CFBundleCopySupportFilesDirectoryURL( bundle: CFBundleRef ): CFURLRef; external name '_CFBundleCopySupportFilesDirectoryURL';
  250. function CFBundleCopyResourcesDirectoryURL( bundle: CFBundleRef ): CFURLRef; external name '_CFBundleCopyResourcesDirectoryURL';
  251. function CFBundleCopyPrivateFrameworksURL( bundle: CFBundleRef ): CFURLRef; external name '_CFBundleCopyPrivateFrameworksURL';
  252. function CFBundleCopySharedFrameworksURL( bundle: CFBundleRef ): CFURLRef; external name '_CFBundleCopySharedFrameworksURL';
  253. function CFBundleCopySharedSupportURL( bundle: CFBundleRef ): CFURLRef; external name '_CFBundleCopySharedSupportURL';
  254. function CFBundleCopyBuiltInPlugInsURL( bundle: CFBundleRef ): CFURLRef; external name '_CFBundleCopyBuiltInPlugInsURL';
  255. { ------------- Basic Bundle Info without a CFBundle instance ------------- }
  256. { This API is provided to enable developers to retrieve basic information }
  257. { about a bundle without having to create an instance of CFBundle. }
  258. { Because of caching behavior when a CFBundle instance exists, it will be faster }
  259. { to actually create a CFBundle if you need to retrieve multiple pieces of info. }
  260. function CFBundleCopyInfoDictionaryInDirectory( bundleURL: CFURLRef ): CFDictionaryRef; external name '_CFBundleCopyInfoDictionaryInDirectory';
  261. function CFBundleGetPackageInfoInDirectory( url: CFURLRef; var packageType: UInt32; var packageCreator: UInt32 ): Boolean; external name '_CFBundleGetPackageInfoInDirectory';
  262. { ==================== Resource Handling API ==================== }
  263. function CFBundleCopyResourceURL( bundle: CFBundleRef; resourceName: CFStringRef; resourceType: CFStringRef; subDirName: CFStringRef ): CFURLRef; external name '_CFBundleCopyResourceURL';
  264. function CFBundleCopyResourceURLsOfType( bundle: CFBundleRef; resourceType: CFStringRef; subDirName: CFStringRef ): CFArrayRef; external name '_CFBundleCopyResourceURLsOfType';
  265. function CFBundleCopyLocalizedString( bundle: CFBundleRef; key: CFStringRef; value: CFStringRef; tableName: CFStringRef ): CFStringRef; external name '_CFBundleCopyLocalizedString';
  266. function CFCopyLocalizedString( key: CFStringRef; comment: PChar ): CFStringRef; inline;
  267. function CFCopyLocalizedStringFromTable( key: CFStringRef; tableName: CFStringRef; comment: PChar ): CFStringRef; inline;
  268. function CFCopyLocalizedStringFromTableInBundle( key: CFStringRef; tableName: CFStringRef; bundle: CFBundleRef; comment: PChar ): CFStringRef; inline;
  269. function CFCopyLocalizedStringWithDefaultValue( key: CFStringRef; tableName: CFStringRef; bundle: CFBundleRef; value: CFStringRef; comment: PChar ): CFStringRef; inline;
  270. { ------------- Resource Handling without a CFBundle instance ------------- }
  271. { This API is provided to enable developers to use the CFBundle resource }
  272. { searching policy without having to create an instance of CFBundle. }
  273. { Because of caching behavior when a CFBundle instance exists, it will be faster }
  274. { to actually create a CFBundle if you need to access several resources. }
  275. function CFBundleCopyResourceURLInDirectory( bundleURL: CFURLRef; resourceName: CFStringRef; resourceType: CFStringRef; subDirName: CFStringRef ): CFURLRef; external name '_CFBundleCopyResourceURLInDirectory';
  276. function CFBundleCopyResourceURLsOfTypeInDirectory( bundleURL: CFURLRef; resourceType: CFStringRef; subDirName: CFStringRef ): CFArrayRef; external name '_CFBundleCopyResourceURLsOfTypeInDirectory';
  277. { =========== Localization-specific Resource Handling API =========== }
  278. { This API allows finer-grained control over specific localizations, }
  279. { as distinguished from the above API, which always uses the user's }
  280. { preferred localizations for the bundle in the current app context. }
  281. function CFBundleCopyBundleLocalizations( bundle: CFBundleRef ): CFArrayRef; external name '_CFBundleCopyBundleLocalizations';
  282. { Lists the localizations that a bundle contains. }
  283. function CFBundleCopyPreferredLocalizationsFromArray( locArray: CFArrayRef ): CFArrayRef; external name '_CFBundleCopyPreferredLocalizationsFromArray';
  284. { Given an array of possible localizations, returns the one or more }
  285. { of them that CFBundle would use in the current application context. }
  286. { To determine the localizations that would be used for a particular }
  287. { bundle in the current application context, apply this function to the }
  288. { result of CFBundleCopyBundleLocalizations(). }
  289. {#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED}
  290. function CFBundleCopyLocalizationsForPreferences( locArray: CFArrayRef; prefArray: CFArrayRef ): CFArrayRef; external name '_CFBundleCopyLocalizationsForPreferences';
  291. { Given an array of possible localizations, returns the one or more of }
  292. { them that CFBundle would use, without reference to the current application }
  293. { context, if the user's preferred localizations were given by prefArray. }
  294. { If prefArray is NULL, the current user's actual preferred localizations will }
  295. { be used. This is not the same as CFBundleCopyPreferredLocalizationsFromArray(), }
  296. { because that function takes the current application context into account. }
  297. { To determine the localizations that another application would use, apply }
  298. { this function to the result of CFBundleCopyBundleLocalizations(). }
  299. {#endif}
  300. function CFBundleCopyResourceURLForLocalization( bundle: CFBundleRef; resourceName: CFStringRef; resourceType: CFStringRef; subDirName: CFStringRef; localizationName: CFStringRef ): CFURLRef; external name '_CFBundleCopyResourceURLForLocalization';
  301. function CFBundleCopyResourceURLsOfTypeForLocalization( bundle: CFBundleRef; resourceType: CFStringRef; subDirName: CFStringRef; localizationName: CFStringRef ): CFArrayRef; external name '_CFBundleCopyResourceURLsOfTypeForLocalization';
  302. { The localizationName argument to CFBundleCopyResourceURLForLocalization() or }
  303. { CFBundleCopyResourceURLsOfTypeForLocalization() must be identical to one of the }
  304. { localizations in the bundle, as returned by CFBundleCopyBundleLocalizations(). }
  305. { It is recommended that either CFBundleCopyPreferredLocalizationsFromArray() or }
  306. { CFBundleCopyLocalizationsForPreferences() be used to select the localization. }
  307. {#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED}
  308. { =================== Unbundled application info ===================== }
  309. { This API is provided to enable developers to retrieve bundle-related }
  310. { information about an application that may be bundled or unbundled. }
  311. function CFBundleCopyInfoDictionaryForURL( url: CFURLRef ): CFDictionaryRef; external name '_CFBundleCopyInfoDictionaryForURL';
  312. { For a directory URL, this is equivalent to CFBundleCopyInfoDictionaryInDirectory(). }
  313. { For a plain file URL representing an unbundled executable, this will attempt to read }
  314. { an info dictionary from the (__TEXT, __info_plist) section, if it is a Mach-o file, }
  315. { or from a 'plst' resource. }
  316. function CFBundleCopyLocalizationsForURL( url: CFURLRef ): CFArrayRef; external name '_CFBundleCopyLocalizationsForURL';
  317. { For a directory URL, this is equivalent to calling CFBundleCopyBundleLocalizations() }
  318. { on the corresponding bundle. For a plain file URL representing an unbundled executable, }
  319. { this will attempt to determine its localizations using the CFBundleLocalizations and }
  320. { CFBundleDevelopmentRegion keys in the dictionary returned by CFBundleCopyInfoDictionaryForURL,}
  321. { or from a 'vers' resource if those are not present. }
  322. {#endif}
  323. function CFBundleCopyExecutableArchitecturesForURL( url: CFURLRef ): CFArrayRef; external name '_CFBundleCopyExecutableArchitecturesForURL';
  324. (* CF_AVAILABLE_STARTING(10_5, 2_0) *)
  325. { For a directory URL, this is equivalent to calling CFBundleCopyExecutableArchitectures() }
  326. { on the corresponding bundle. For a plain file URL representing an unbundled executable, }
  327. { this will return the architectures it provides, if it is a Mach-o file, or NULL otherwise. }
  328. { ==================== Primitive Code Loading API ==================== }
  329. { This API abstracts the various different executable formats supported on }
  330. { various platforms. It can load DYLD, CFM, or DLL shared libraries (on their }
  331. { appropriate platforms) and gives a uniform API for looking up functions. }
  332. { Note that Cocoa-based bundles containing Objective-C or Java code must }
  333. { be loaded with NSBundle, not CFBundle. Once they are loaded, however, }
  334. { either CFBundle or NSBundle can be used. }
  335. function CFBundleCopyExecutableURL( bundle: CFBundleRef ): CFURLRef; external name '_CFBundleCopyExecutableURL';
  336. {#if MAC_OS_X_VERSION_10_5 <= MAC_OS_X_VERSION_MAX_ALLOWED}
  337. const
  338. kCFBundleExecutableArchitectureI386 = $00000007;
  339. kCFBundleExecutableArchitecturePPC = $00000012;
  340. kCFBundleExecutableArchitectureX86_64 = $01000007;
  341. kCFBundleExecutableArchitecturePPC64 = $01000012;
  342. {#endif} { MAC_OS_X_VERSION_10_5 <= MAC_OS_X_VERSION_MAX_ALLOWED }
  343. function CFBundleCopyExecutableArchitectures( bundle: CFBundleRef ): CFArrayRef; external name '_CFBundleCopyExecutableArchitectures';
  344. (* CF_AVAILABLE_STARTING(10_5, 2_0) *)
  345. { If the bundle's executable exists and is a Mach-o file, this function will return an array }
  346. { of CFNumbers whose values are integers representing the architectures the file provides. }
  347. { The values currently in use are those listed in the enum above, but others may be added }
  348. { in the future. If the executable is not a Mach-o file, this function returns NULL. }
  349. function CFBundlePreflightExecutable( bundle: CFBundleRef; var error: CFErrorRef ): Boolean; external name '_CFBundlePreflightExecutable';
  350. (* CF_AVAILABLE_STARTING(10_5, 2_0) *)
  351. { This function will return true if the bundle is loaded, or if the bundle appears to be }
  352. { loadable upon inspection. This does not mean that the bundle is definitively loadable, }
  353. { since it may fail to load due to link errors or other problems not readily detectable. }
  354. { If this function detects problems, it will return false, and return a CFError by reference. }
  355. { It is the responsibility of the caller to release the CFError. }
  356. function CFBundleLoadExecutableAndReturnError( bundle: CFBundleRef; var error: CFErrorRef ): Boolean; external name '_CFBundleLoadExecutableAndReturnError';
  357. (* CF_AVAILABLE_STARTING(10_5, 2_0) *)
  358. { If the bundle is already loaded, this function will return true. Otherwise, it will attempt }
  359. { to load the bundle, and it will return true if that attempt succeeds. If the bundle fails }
  360. { to load, this function will return false, and it will return a CFError by reference. }
  361. { It is the responsibility of the caller to release the CFError. }
  362. function CFBundleLoadExecutable( bundle: CFBundleRef ): Boolean; external name '_CFBundleLoadExecutable';
  363. function CFBundleIsExecutableLoaded( bundle: CFBundleRef ): Boolean; external name '_CFBundleIsExecutableLoaded';
  364. procedure CFBundleUnloadExecutable( bundle: CFBundleRef ); external name '_CFBundleUnloadExecutable';
  365. function CFBundleGetFunctionPointerForName( bundle: CFBundleRef; functionName: CFStringRef ): UnivPtr; external name '_CFBundleGetFunctionPointerForName';
  366. procedure CFBundleGetFunctionPointersForNames( bundle: CFBundleRef; functionNames: CFArrayRef; ftbl: {variable-size-array} UnivPtrPtr ); external name '_CFBundleGetFunctionPointersForNames';
  367. function CFBundleGetDataPointerForName( bundle: CFBundleRef; symbolName: CFStringRef ): UnivPtr; external name '_CFBundleGetDataPointerForName';
  368. procedure CFBundleGetDataPointersForNames( bundle: CFBundleRef; symbolNames: CFArrayRef; stbl: {variable-size-array} UnivPtrPtr ); external name '_CFBundleGetDataPointersForNames';
  369. function CFBundleCopyAuxiliaryExecutableURL( bundle: CFBundleRef; executableName: CFStringRef ): CFURLRef; external name '_CFBundleCopyAuxiliaryExecutableURL';
  370. { This function can be used to find executables other than your main }
  371. { executable. This is useful, for instance, for applications that have }
  372. { some command line tool that is packaged with and used by the application. }
  373. { The tool can be packaged in the various platform executable directories }
  374. { in the bundle and can be located with this function. This allows an }
  375. { app to ship versions of the tool for each platform as it does for the }
  376. { main app executable. }
  377. { ==================== Getting a bundle's plugIn ==================== }
  378. function CFBundleGetPlugIn( bundle: CFBundleRef ): CFPlugInRef; external name '_CFBundleGetPlugIn';
  379. { ==================== Resource Manager-Related API ==================== }
  380. {$ifc TARGET_CPU_64}
  381. type
  382. CFBundleRefNum = SInt32;
  383. {$elsec}
  384. type
  385. CFBundleRefNum = SInt16;
  386. {$endc}
  387. function CFBundleOpenBundleResourceMap( bundle: CFBundleRef ): CFBundleRefNum; external name '_CFBundleOpenBundleResourceMap';
  388. { This function opens the non-localized and the localized resource files }
  389. { (if any) for the bundle, creates and makes current a single read-only }
  390. { resource map combining both, and returns a reference number for it. }
  391. { If it is called multiple times, it opens the files multiple times, }
  392. { and returns distinct reference numbers. }
  393. function CFBundleOpenBundleResourceFiles( bundle: CFBundleRef; var refNum: CFBundleRefNum; var localizedRefNum: CFBundleRefNum ): SInt32; external name '_CFBundleOpenBundleResourceFiles';
  394. { Similar to CFBundleOpenBundleResourceMap(), except that it creates two }
  395. { separate resource maps and returns reference numbers for both. }
  396. procedure CFBundleCloseBundleResourceMap( bundle: CFBundleRef; refNum: CFBundleRefNum ); external name '_CFBundleCloseBundleResourceMap';
  397. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  398. implementation
  399. {$R-}
  400. function CFCopyLocalizedString( key: CFStringRef; comment: PChar ): CFStringRef; inline;
  401. begin
  402. CFCopyLocalizedString := CFBundleCopyLocalizedString( CFBundleGetMainBundle, key, key, nil );
  403. end;
  404. function CFCopyLocalizedStringFromTable( key: CFStringRef; tableName: CFStringRef; comment: PChar ): CFStringRef; inline;
  405. begin
  406. CFCopyLocalizedStringFromTable := CFBundleCopyLocalizedString( CFBundleGetMainBundle, key, key, tableName );
  407. end;
  408. function CFCopyLocalizedStringFromTableInBundle( key: CFStringRef; tableName: CFStringRef; bundle: CFBundleRef; comment: PChar ): CFStringRef; inline;
  409. begin
  410. CFCopyLocalizedStringFromTableInBundle := CFBundleCopyLocalizedString( bundle, key, key, tableName );
  411. end;
  412. function CFCopyLocalizedStringWithDefaultValue( key: CFStringRef; tableName: CFStringRef; bundle: CFBundleRef; value: CFStringRef; comment: PChar ): CFStringRef; inline;
  413. begin
  414. CFCopyLocalizedStringWithDefaultValue := CFBundleCopyLocalizedString( bundle, key, value, tableName );
  415. end;
  416. end.
  417. {$endc} {not MACOSALLINCLUDE}