Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: kMDItemTextContent... where is it?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: kMDItemTextContent... where is it?



Hi Hank,

kMDItemTextContent is the one attribute that's query-only.  Spotlight's index doesn't store the original text of the document at all, so you can't get it from there.  As for Quick Look, each type of file has a plug-in, which understands how to read in and display a given file format.  There's no "magic" in either case, just code to do the heavy lifting.

If you're looking at getting access to the contents of a file, I'd recommend just reading the file into a buffer (or mapped memory, if it might be large) and then displaying the contents of the buffer.  In cocoa, this is a trivial thing to do.

-Jonah

On Mar 5, 2009, at 9:57 AM, HAMSoft Admin wrote:

Hi all,

I'm new to the list so please bear with me. I don't know anywhere I can search the previous posts of this discussion board and google hasn't been any help.

I'm writing a program and I need to access the contents of the files that are returned after an MDQuery. I can get the file paths from the query and then just read in the file contents manually, but I'm wondering if I can get this information directly from the query results. After all spotlight can search by contents so I think there must be a way. After some searching I found the kMDItemTextContent field but when I access that field from the query results I always get NULL returned instead of the file contents.

I'm also looking at how QuickLook can display the file contents. For example, with an applescript file spotlight does not index their code without a 3rd party plugin. But if I pull up the QuickLook window for an applescript file the code is displayed. So I'm wondering how QuickLook gets the text of a file too.

I'm hoping someone can point me in the right direction of how to access the code of files without manually reading in the code text. I hoping I can get it right from an MDQuery of some kind of QuickLook query.

Sincerely,
Hank McShane
HAMSoft Engineering
<ATT00001.txt>

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Spotlight-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >kMDItemTextContent... where is it? (From: HAMSoft Admin <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.