2013/10/21 CW Alston <cwalsto...@gmail.com>:
> :: <mdfind-request> ( filename -- seq )
>          "'kMDItemFSName == " filename tri-quotes-surround append  "'"
> append ;
>
> : <mdfind-process> ( filename -- process )
>      <mdfind-request>        ! ( -- seq )
>  '[ "mdfind" , "-onlyin" , "/" , _ , ">" ,
> "/Users/cwalston/factor/mdfind.txt" , ]
>  { } make      ! ( -- seq )
>       <process> swap >>command
>       t >>detached clone  ! ( -- process )
> ;
>
> And then, "Finding Joy in Combinators.pdf" <mdfind-process> contains a
> command
> sequence that looks like this:
> {
>     "mdfind"
>     "-onlyin"
>     "/"
>     "'kMDItemFSName == \"Finding Joy in Combinators.pdf\"'"
>     ">"
>     "/Users/cwalston/factor/mdfind.txt"
> }

The command>> attribute in <process> should be a string not a sequence
of strings. I think that is the core of your problem, not sure. Also,
input and output redirection is a feature of the shell, not the os, so
you need to wrap those commands in a subshell. But that is platform
dependent since not all shells are available everywhere and they dont
all have the same features. Here is how you could write a find utility
for Windows (using gnu find), maybe you can use it as a template:

USING: formatting io.launcher kernel ;
IN: cmdpipe

CONSTANT: find-bin "C:\\Program Files (x86)\\Git\\bin\\find.exe"

: shell-command ( str -- str' )
    "cmd /C \"%s\"" sprintf ;

: find-command ( dir pattern out-path -- str )
    [ find-bin ] 3dip "\"%s\" \"%s\" -name \"%s\" > \"%s\"" sprintf ;

: run-find ( dir pattern out-path -- proc )
    find-command shell-command run-process ;

IN: scratchpad "C:\\Users\\bjourne\\Downloads" "*.pdf"
"C:\\Users\\bjourne\\result.txt" run-find


-- 
mvh/best regards Björn Lindqvist

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to