سؤال

I am writing application specific documents from a Java application. These documents are basically a collection of related files / database within one directory. On OS X I would like to have this directory appear opaque as if it was one document file, similar as RTFD hides an RTF text file along with associated resources (such as pasted graphics). I understand this concept is called package.

For example, imagine this structure:

MyDocument.ext/
   MetaData.xml
   Database/
     Db0
     Db1

etc. I would like this to appear in the Finder as a document MyDocument, not a directory.

I will be able to produce an app bundle for my Java application, so that could contain a document descriptor in its Info.plist.

How would I tell the OS X to treat my documents (directories) this way? Via the Info.plist, or do I need to execute some particular terminal program?

هل كانت مفيدة؟

المحلول

Following this document, indeed only an entry in the application's plist is needed: In the document type entry, the key LSTypeIsPackage must be included with value "true":

<key>CFBundleDocumentTypes</key>
<array>
  <dict>
    <key>CFBundleTypeRole</key>
    <string>Editor</string>
    <key>CFBundleTypeName</key>
    <string>Foobar Document</string>
    <key>CFBundleTypeExtensions</key>
    <array>
      <string>foobar</string>
    </array>
    <key>LSTypeIsPackage</key>
    <string>true</string>       <!-- !!! -->
    <key>CFBundleTypeIconFile</key>
    <string>foobar.icns</string>
  </dict>
</array>

I had to copy the application to /Applications for the Finder to recognise my new file type, but then it worked, and the directories ending in .foobar are shown as opaque files.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top