- AECoerceDesc (theItem, typeFSRef, theItem);
-
- FSRef fsref ;
- if ( AEGetDescData (theItem, &fsref, sizeof (FSRef)) == noErr )
+ // 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;
+ }
+ else
+ {
+ AECoerceDesc (theItem, typeFSRef, theItem);
+ if ( AEGetDescData (theItem, &fsref, sizeof (FSRef)) == noErr)