Spotlight, file extension, UTI and OS Type?
Spotlight, file extension, UTI and OS Type?
- Subject: Spotlight, file extension, UTI and OS Type?
- From: Peter Borg <email@hidden>
- Date: Sun, 8 May 2005 17:37:28 +0200
Hi!
I have a text editor to which I would like to add Spotlight indexing
even for those files that don't have a file extension but my OS Type
(if I save those files with .txt there's no problem and they are
indexed automatically, but I would like not to have to do that).
So I included an UTI (org.smultron.smultron.smld) along with the OS
Type in Xcode and added a UTI export declaration to the Info.plist
like this:
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeIdentifier</key>
<string>org.smultron.smultron.smld</string>
<key>UTTypeDescription</key>
<string>Smultron document</string>
<key>UTTypeIconName</key>
<string>documentIcon.icns</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.plain-text</string>
</array>
<key>UTTypeTagSpecification</key>
<dict>
<key>com.apple.ostype</key>
<string>SMLd</string>
</dict>
</dict>
</array>
And as it conforms to public.plain-text I had hoped that it would
automatically be indexed as a plain-text document if it couldn't find
its own importer, but no such luck - it just said that the importer
was missing. (But one could see with "mdimport -d2 theFile" that the
file was "tagged" correctly.) So I wrote an importer (which just set
the kMDItemTextContent and kMDItemKind keys) for
org.smultron.smultron.smld (which was very easy, thanks Apple!) and
everything seemed dandy (at least after a "mdimport -r theImporter", I
don't know if there's a special length of time before it starts to do
it by itself...) and saved files were indexed even if they had no file
extension. But then I discovered something which seems strange to me;
if I opened a e.g. .html file which had the "right" (i.e. my
applications) creator and type (and icon) in my text editor and saved
it again, it suddenly changed the icon to Safaris html icon and if I
double clicked it it opened in Safari, but it still had the "right"
creator and type. So it seems to me that if I save a file without
extension it still belongs to my application but if I use an extension
that already has a Spotlight importer it changes "ownership". (And if
I remove all this UTI "stuff" it works again just I would like it to,
if I save a .html it "belongs" to my application.)
So my questions are:
1) Is there a way that I can tell Spotlight to automatically index
files with my OS Type (or UTI) as plain-text even if they don't have a
file extension or, maybe even, if they have an extension that is
already used e.g. .html?
2) Why does the system change "ownership" of my files that have a file
extension if I have a UTI and can I do something about it?
Or am I trying to do something that can't be done? Does Spotlight
always need a file extension to properly keep track of files? Right
now I'm in that weird place where I don't know if I've missed
something fundamental or if it simply just can't be done...
Cheers,
Peter Borg
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden