Greetings, Factorials -
I've posted a vocab to the pastebin, a Factor interface to OS X
Spotlight<http://paste.factorcode.org/new-paste?__c=9053524212955052707>
.
Pardon the length; this should be split into at least 2 code files &
a docs file. Just seems best to show everything together for the post.
The general strategy is to compose a Spotlight query as a command-line
one-liner
and write that to an executable shell script file; then, launch a Factor
process
that calls that executable. The script directs the shell output to a named
text file, whose contents are returned to Factor as a sequence of
file-lines.
OS X exposes 4 commands that deal with Spotlight via its MetaData index:
mdfind, mdls, mdutil, mdimport (see their man pages for details).
Implementing
mdfind was my main aim, but getting at all 4 from Factor seemed worth the
effort.
What a rabbit hole! I had to console myself with frequent laughter breaks
reading
*The Unix-Hater's Handbook* (*q.v.*). Oy!!
To try out the code, you'll need to put a plain-text file in some
convenient path,
to receive query results. Also, set up an executable file somewhere; your
command-
line scripts will be written there. You can modify the paths to these 2
files,
& the form of the hashbang, to suit convenience & your shell. Just be
consistent
with what the code expects. (Dont forget to put the pastebin code in a
folder named
"spotlight", within your "work" folder, to exercise it in the listener.)
I'd appreciate it if folks would try the examples (modifying paths &
filenames),
compose arbitrary queries; see what breaks, is cumbersome, impossible, or
goofy;
and suggest improvements or alternative approaches for working with
Spotlight.
Alex's suggestion of using streams seems more intuitive & direct to me, but
I
foundered wading those waters.
And, yeah, I'm hip - a ridiculous plethora of string CONSTANT:s. A few are
just composition crutches, and overkill. The majority seem to suit this
approach.
See what you think.
Do take a look at the code, if you have an interest, and opine away.
Cheers,
CW Alston
--
*~ Memento Amori*
------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk