- if (theItem->descriptorType == typeFSS )
- {
- FSSpec spec;
- memcpy( &spec , *theItem->dataHandle , sizeof(FSSpec) ) ;
- wxString file = wxMacMakeStringFromPascal( spec.name ) ;
- display = CheckFile( file , theInfo->fileAndFolder.fileInfo.finderInfo.fdType , data ) ;
- }
- else if ( theItem->descriptorType == typeFSRef )
- {
- FSRef fsref ;
- 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;