Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jun 3, 2013, 07:35 PM   #1
ArtOfWarfare
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
How does OS X associate file extensions with apps?

I'd like to make a small utility that makes it a breeze to associate hundreds of file extensions with a single app and to use a single quick look plugin all at once.

My understanding is that there's a property defined in each app bundle's info.plist that says which file extensions it associates with, but then the contents of this property are copied to some master file somewhere from time to time.

Does anyone know where that master file is?

Or should I just modify the chosen app's info.plist?
__________________
Battery Status - On the Mac App Store
The only app that'll estimate when your wireless devices will need their batteries changed.
Including the ones paired with other Macs on your network.
ArtOfWarfare is offline   0 Reply With Quote
Old Jun 4, 2013, 07:02 AM   #2
robbieduncan
Moderator
 
robbieduncan's Avatar
 
Join Date: Jul 2002
Location: London
1) Do not ever modify another apps Info.plist: this will break code signing which will prevent them running if signed.

2) Launch Services maintains the database of associations.
robbieduncan is offline   1 Reply With Quote
Old Jun 4, 2013, 07:05 AM   #3
ArtOfWarfare
Thread Starter
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
Quote:
Originally Posted by robbieduncan View Post
1) Do not ever modify another apps Info.plist: this will break code signing which will prevent them running if signed.
Okay, that makes sense. The things I was reading that said it was a viable option were all from between 2003 and 2005, so I was checking if anyone had newer answers.

I'll look at the link you shared - thanks!

Edit: Quick related question:

Does a file itself contain its own MIME type - or is that some kind of meta data from outside the file?

Last edited by ArtOfWarfare; Jun 4, 2013 at 08:09 AM.
ArtOfWarfare is offline   0 Reply With Quote
Old Jun 12, 2013, 12:27 PM   #4
Madd the Sane
macrumors 6502
 
Join Date: Nov 2010
Location: Utah
To my knowledge, Launch Services can map MIME data to document definitions and/or a UTI. But as far as storing MIME type for a file, it doesn't do that.

Last edited by Madd the Sane; Jun 12, 2013 at 11:49 PM. Reason: completing a thought
Madd the Sane is offline   0 Reply With Quote
Old Jun 12, 2013, 11:35 PM   #5
ratsg
macrumors regular
 
Join Date: Dec 2010
all of the above is accurate, at least as far as I know.

Just to be complete, my rule of thumb for app associations is:

dos/windows - file name extension.
older Mac OS - resource fork
Unix - pulled from /etc/magic

I just looked in my 10.6.x server, and I don't see a /etc/magic file. I *thought* a magic file was there, maybe in older versions and Apple has more recently pulled it.

Again, on my 10.6.x Server, I do have (2) magic files, one in each of these directories.

/private/etc/apache2/magic
/usr/share/file/magic/magic

Hope this is of some value to you.
ratsg is offline   0 Reply With Quote
Old Jun 12, 2013, 11:48 PM   #6
Madd the Sane
macrumors 6502
 
Join Date: Nov 2010
Location: Utah
I think the Spotlight service also uses the magic file
__________________
Get out of my mind, idea! I already have an idea in here!
Madd the Sane is offline   0 Reply With Quote
Old Jun 26, 2013, 06:34 AM   #7
Meir David
macrumors newbie
 
Join Date: Jun 2013
hi dude

When a user drags an application into the Applications folder, the system should register it with Launch Services automatically.

See Application Registration in the Launch Services Guide.
Meir David is offline   0 Reply With Quote
Old Jun 26, 2013, 08:44 PM   #8
kaydell.leavitt
macrumors regular
 
Join Date: Apr 2010
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/...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...le_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.
kaydell.leavitt is offline   0 Reply With Quote
Old Jun 27, 2013, 07:03 AM   #9
MeFromHere
macrumors regular
 
Join Date: Oct 2012
Quote:
Originally Posted by kaydell.leavitt View Post
...
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.
...
Why doesn't the functionality in Finder's "Get Info" window suffice? There's an "Open with" popdown menu and a "Change All..." button.
MeFromHere is offline   0 Reply With Quote
Old Feb 2, 2014, 01:49 PM   #10
IrishMafia
macrumors newbie
 
Join Date: Dec 2011
Get Info Works

As was suggested earlier, Get Info works! I loaded a new program that took my file association for .m4v away from Quicktime. I selected a movie file and changed the "Open With" back to Quicktime along with "Change All.."

It just works.
IrishMafia is offline   0 Reply With Quote
Old Feb 2, 2014, 09:51 PM   #11
ArtOfWarfare
Thread Starter
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
Quote:
Originally Posted by IrishMafia View Post
As was suggested earlier, Get Info works! I loaded a new program that took my file association for .m4v away from Quicktime. I selected a movie file and changed the "Open With" back to Quicktime along with "Change All.."

It just works.
Yes, but I was asking about making this change with several file types all at once.
ArtOfWarfare is offline   0 Reply With Quote
Old Mar 4, 2014, 09:07 PM   #12
jlettvin
macrumors newbie
 
Join Date: Mar 2014
I agree with the original thread starter

The answers fail utterly to achieve his/her goal.
I have the same problem, and same goal.
I want VLC to be my universal movie player
and never again see QuickTime
open and corrupt my library of math lectures.
I have unrecoverably lost half a dozen movies.

A utility to meet my need would be useful
if it made any/all new movie types I give it
launch VLC instead of QuickTime or, less comforting,
if I could give it a list of all known movie extensions
and associate VLC with all those extensions.

Anything else leaves me at risk of destroying
more of my precious lecture movies.

So, I second the thread starter's request.
I was unable to grasp enough of the Mac ecosystem
to do it myself. Maybe in time...
But the learning curve for this linux heavy is steep.
jlettvin is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
cannot rename file names of folders, files, or change case of file extensions Sossity Mac Basics and Help 8 Apr 2, 2013 05:38 AM
File Extensions Rockoar OS X 10.8 Mountain Lion 3 Dec 9, 2012 04:01 PM
Making AI or PDF file from any GIMP file extensions without loss of quality? twiggy0 Design and Graphics 6 Aug 29, 2012 11:25 PM
how associate os x guest file ext to run host application oharamj Mac Basics and Help 0 Aug 5, 2012 07:02 PM
Nothing in my Extensions file. Zerosangheili Mac Applications and Mac App Store 2 Jun 8, 2012 11:45 PM

Forum Jump

All times are GMT -5. The time now is 12:34 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC