Identifying bundles in MacOS X

Greg Ewing greg at cosc.canterbury.ac.nz
Tue Nov 16 03:46:01 CET 2004


Michael J. Fromberger wrote:
> Given the pathname of a directory in my filesystem, I would like a 
> graceful way to determine whether or not that directory represents a 
> "bundle", in the sense that, when you double-click on the directory's 
> icon in the Finder, it is launched rather than "opened" for viewing.
> Applications behave this way by default, but so do various other file 
> types (e.g., the "rtfd" files created by TextEdit, and the data files 
> for certain applications such as Quicken).

I think that a MacOSX-style application can be recognised
simply by the fact that it's a directory whose name ends
in ".app". (You don't usually see that extension in the
Finder, but all MacOSX application bundles seem to have it.)

A Classic-style application is a file with a type code
of "APPL".

As for other files, they can be associated with applications
using either the old type/creator code system, or the new
filename-extension-based system (which is disappointingly
Windows-like, but sadly seems to be the dictated Way of
the Future :-(.)

The type and creator of a file can be found using FSpGetInfo.
You're right that this doesn't work for directories, but
directories don't have type/creator codes anyway. MacOSX
bundles seem to be recognised purely by filename suffix
(and possibly also by having the right internal structure).

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg




More information about the Python-list mailing list