- AECoerceDesc (theItem, typeFSRef, theItem);
-
- FSRef fsref ;
- if ( AEGetDescData (theItem, &fsref, sizeof (FSRef)) == noErr )
- {
- memcpy( &fsref , *theItem->dataHandle , sizeof(FSRef) ) ;
- wxString file = wxMacFSRefToPath( &fsref ) ;
- display = CheckFile( file , theInfo->fileAndFolder.fileInfo.finderInfo.fdType , data ) ;
- }
+ // check bundle bit (using Finder Services - used by OS9 on some bundles)
+ FSCatalogInfo catalogInfo;
+ if (FSGetCatalogInfo (&fsref, kFSCatInfoFinderInfo, &catalogInfo, NULL, NULL, NULL) != noErr)
+ return true;
+
+ // Check bundle item (using Launch Services - used by OS-X through info.plist or APP)
+ LSItemInfoRecord lsInfo;
+ if (LSCopyItemInfoForRef(&fsref, kLSRequestBasicFlagsOnly, &lsInfo ) != noErr)
+ return true;
+
+ // If it's not a bundle, then it's a normal folder and it passes our filter
+ FileInfo *fileInfo = (FileInfo *) catalogInfo.finderInfo;
+ if ( !(fileInfo->finderFlags & kHasBundle) &&
+ !(lsInfo.flags & (kLSItemInfoIsApplication | kLSItemInfoIsPackage)) )
+ return true;