here is how to do it in a CARBON app… anyone have COCOA replacement?
Soft Declare Function LSCopyItemInfoForRef Lib CarbonFramework (byref inItemRef as fsRef, inWhichInfo as Integer, byref outItemInfo as lsItemInfoRecord) as Integer
Dim theRef as FSRef
Dim itemInfo as LSItemInfoRecord
Const kLSRequestBasicFlagsOnly = &hFFFFFFFF //&h00000004
Const kLSItemInfoIsPackage = &h00000002
theRef = GetFSRefFromFolderItem(f)
OSError = LSCopyItemInfoForRef(theRef, kLSRequestBasicFlagsOnly, iteminfo)
If OSError <> 0 then
//Raise new MacOSException("LSCopyItemInfoForRef", OSError)
Return Bitwise.BitAnd(itemInfo.flags, kLSItemInfoIsPackage)=kLSItemInfoIsPackage
[quote=43143:@Michel Bujardet]I use GetOpenFolderItem() to let the user pick file names. But it is possible to select either files, or bundles, with the same dialog.
Is there a way to I find out after selection by the user if a folderitem is a file, or a bundle ? I need that to process differently these items.
Yes and yes. Once a bundle is correctly created, it will show up in a Open Dialog as a regular file. The easiest way to tell, is to check folder item.directory property as a bundle, being a folder will have this field set.
For future reference, while this technique will work absolutely fine from the Open Dialog (because you have to use a different dialog to actually get folders), it may not be so reliable from Drag & Drop or if the user opens the application by dropping a folder/package/file onto the app icon.
However, once you’ve set up a file type object for your file type, you should be able to test folderitem.type to see if it matches.