Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I want to have an extension, named .content, to store all files in it that are linked to the filename. The extension ".content" should be recognized by the OS as a file extension rather than a regular map. The files in the extension should be only reached by opening the extension by the option "Show Package Contents". I hope someone can offer me a solution to my problem.

share|improve this question
    
This is Off topic here this is a question about writing an application. SO better on StackOverflow. However as a start look at Apple's bundle doc –  Mark Apr 29 '13 at 18:00
    
Mark - If the implied question is how to develop an app, then yes, this is off-topic, however there is lots of room to answer how things work and perhaps let the OP edit an existing app to see if they can tweak the launch services database to suit their needs. It's more of a "not detailed enough" question and I wouldn't object to it being closed for that reason since more detail is needed to really know what the OP wants. –  bmike Apr 29 '13 at 18:18

2 Answers 2

up vote 1 down vote accepted

Folders that end with .bundle already act that way. They are opened in Terminal by default though.

The file type is defined in /System/Library/CoreServices/CoreTypes.bundle/Contents/Info.plist:

<dict>
    <key>UTTypeConformsTo</key>
    <array>
        <string>com.apple.bundle</string>
        <string>com.apple.package</string>
    </array>
    <key>UTTypeDescription</key>
    <string>bundle</string>
    <key>UTTypeIdentifier</key>
    <string>com.apple.generic-bundle</string>
    <key>UTTypeTagSpecification</key>
    <dict>
        <key>com.apple.ostype</key>
        <string>BNDL</string>
        <key>public.filename-extension</key>
        <string>bundle</string>
    </dict>
</dict>

To make folders that end with .content be treated as packages, add an entry like this:

<dict>
    <key>UTTypeConformsTo</key>
    <array>
        <string>com.apple.bundle</string>
        <string>com.apple.package</string>
    </array>
    <key>UTTypeIdentifier</key>
    <string>my.content</string>
    <key>UTTypeTagSpecification</key>
    <dict>
        <key>public.filename-extension</key>
        <string>content</string>
    </dict>
</dict>

Then rebuild the Launch Services database to apply the changes:

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -domain local -domain system -domain user

You could also add this to a CFBundleDocumentTypes array in the Info.plist of any application:

<dict>
    <key>CFBundleTypeExtensions</key>
    <array>
        <string>content</string>
    </array>
    <key>CFBundleTypeRole</key>
    <string>None</string>
    <key>LSTypeIsPackage</key>
    <true/>
</dict>

To apply changes, rebuild the Launch Services database or touch the application bundle. If the application is signed, modifying the Info.plist invalidates the code signature though.

share|improve this answer

OS X ships with a set of extensions that map to specific applications (and most of these map to Apple provided apps) so you could petition Apple to make the change, but that would be unlikely.

The other mechanism to inject a specific .extension to Application mapping into the Launch Services database is to install an Application that tells the system to map certain file types and extensions to that specific Application.

So, to keep things on-topic here let's just direct you to Stack Overflow to ask how to make your own Application. If you're not looking to develop an application, you could also just modify the app you want to open your custom file extension by changing it's interal info.plist file:

Sorry if this level of detail is more technical than you want, but I wanted to answer this for anyone that needs to know how to modify things.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.