Some History of File Types on the Mac
Back in Classic Mac OS, each document has an OSType which was a 4 character file type such as "TEXT" for a text file, and file name extensions were just a part of the file name and had no special meaning.
When OS X came out, it was Unix so, file name extensions came into use with Mac OS X. They are hidden by default in the Finder, but they are visible in Terminal.app and they are visible in Finder.app if you go into Finder > Preferences > Advanced Preferences > Show all filename extensions and check this check box.
OS X still has the OSType in application bundles. Application bundles are really just folders with the .app extension. You can open them up in Finder by right-clicking on them and choosing "Show Package Contents" from the context menu. If you look around, you can find a file called "PkgInfo", it contains two OSTypes one is the document type which is "AAPL" which stands for "application" and the second OSType is what's called the "creator signature".
This OSType stuff is a carry-over from the Mac Classic OS era, but it is still around.
I'll echo what somebody else said. Don't change any applications in any way!!!.
In the Classic Mac OS, when a user opened a document from the Finder, the Finder would look at the creator signature to see which document created it and would open that application.
Back in the Classic era, each file was potentially two files in one. 1) a data fork, and 2) a resource fork, and there were some file attributes which were only used on Macs and you could lose the resource fork and Apple's file attributes if you transferred the file to a computer that wasn't a Mac.
Nowadays, OS X apps *can* create documents with a resource fork, but they usually don't or if they do, they don't store anything critical in the resource fork.
Somebody else mentioned "Launch Services". This seems like a "clean" way to go, to go through one of Apple's API functions:
LSSetDefaultRoleHandlerForContentType
https://developer.apple.com/library...nchServicesReference/Reference/reference.html
In addition to OSType and filename extension, there is another way to type files that's used now called Uniform Type Identifiers (UTI). Here is a link to that sort of thing in Wikipedia:
http://en.wikipedia.org/wiki/Uniform_Type_Identifier#Apple_public_UTIs
So in the history of Mac OS, a text file could be typed in the following manners:
1. OSType of "TEXT"
2. file name extension of ".txt", or ".java", or ".c" or ".cpp", etc, etc, etc.
or
3. A UTI of "public.text"
Then there's the MIME types which are more specific than just saying that something is text. For example:
JavaScript:
"text/javascript"
CSS:
"text/css"
HTML:
"text/html"
So, a file can be typed so many different ways, it can be confusing. When you figure it all out, let me know.
-- Kaydell
kaydell@yahoo.com
http://learnmacprogramming.com
Whatever you do, don't write to one of Apple's files that is somewhere or change an application in any way.
I could really use an application like the one that you're writing to change all text files with whatever extension to open up with BBEdit.
Though, be careful not to annoy people by changing file type associations behind people's backs you want to put the user in charge.
If you need a beta-user or if you have any more questions, you can send me an email. I'd love to hear from you.