Re: Spotlight Importer
Re: Spotlight Importer
- Subject: Re: Spotlight Importer
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Thu, 28 Feb 2008 09:26:24 +0100
From: "Sean McBride" <email@hidden>
On 2/26/08 12:45 AM, Quincey Morris said:
On Feb 26, 2008, at 00:16, Gerriet M. Denkmann wrote:
I have an application (10.4.11) which creates simple text files
(utf-8 or utf-16).
When I store some document as "myNewFile" then Spotlight does know
nothing about it's content.
But when I store the same file as "myNewFile.txt" then all is fine.
Is there a way to tell Spotlight to treat all files with
NSFileHFSCreatorCode = 'MyAp' as if it had a ".txt" file extention?
Or: if NSFileHFSCreatorCode = 'MyAp' then treat it as public.plain-
text (unless the file extention says otherwise).
Your file is going to need a application-defined UTI, which is
defined
in the app's info.plist file. That private UTI definition can also
equate your private HFS creator code to the private UTI, but there's
not much point in using that mechanism if you're saving the file with
a UTI anyway. I'm guessing that spotlight will happily index a file
with UTI public.plain-text.something-your-application-defined as a
text file, but I don't know for sure.
UTIs have no connection to creator codes. A UTI is defined in
terms of:
a) filename extension
b) HFS type code
c) MIME type
A UTI _cannot_ be attached to a file as metadata, and a UTI cannot be
determined by the system by examining the file's contents.
If a file has no filename extension and no HFS type, then no creator
code will help you, custom importer or not.
Gerriet, could you give your files an HFS type of 'TEXT'? If not,
give
them a unique HFS type and make your own UTI declaration.
I have done:
If the file has no extention and the creator code is 'MyAp' then set
NSFileHFSTypeCode to either 'utf8' or 'ut16' as recommended in
"Uniform Type Identifiers Overview".
> /usr/bin/mdimport -d1 SomeFile
2008-02-28 08:26:20.919 mdimport[626] Import 'SomeFile' type
'public.utf8-plain-text' no mdimporter
> mv SomeFile SomeFile.txt
> /usr/bin/mdimport -d1 SomeFile.txt
2008-02-28 08:26:57.440 mdimport[628] Import 'SomeFile.txt' type
'public.plain-text' using 'file://localhost/System/Library/Spotlight/
RichText.mdimporter/'
So: the "RichText.mdimporter" does public.plain-text, but not
public.utf8-plain-text, although this conforms to public.plain-text.
Now I tried 'TEXT' as you had suggested:
2008-02-28 08:47:18.885 mdimport[658] Import 'TEXTFile' type
'com.apple.traditional-mac-plain-text' using 'file://localhost/System/
Library/Spotlight/RichText.mdimporter/'
But (not really surprising) Spotlight does not find any strings which
are not ascii (or maybe mac-roman). So this is useless.
Adding .txt to the filename is also useless, because Spotlight can
not handle utf for these files.
Conclusion: as rtf files seem to be the only ones where Spotlight can
handle characters outside of ascii, and as converting my plain text
files to rtf is just not an option - there is just nothing (as far as
I can see) what I can do.
Maybe Spotlight in Leopard is better. But I am on 10.4.11.
Gerriet.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden