[Larceny-users] directory-files

Sven.Hartrumpf at FernUni-Hagen.de Sven.Hartrumpf at FernUni-Hagen.de
Tue Jan 30 16:21:53 EST 2007


Mon, 29 Jan 2007 22:45:48 -0500, felixluser wrote:

>
> On Jan 29, 2007, at 5:18 AM, Sven.Hartrumpf at FernUni-Hagen.de wrote:
>
> > Is there a function in Larceny like
> >
> > http://www.shiro.dreamhost.com/scheme/wiliki/schemexref.cgi?
> > directory-files
> >
> > I have searched the Larceny svn tree but could not find anything.
>
> To my knowledge, there is not such a function in Larceny.
>
> Which is unfortunate because it is not easy to write such a function
> with the primitives offered by (native and Petit) Larceny.  The only
> options I can think of are to either go through the FFI to implement
> your own routine to do directory listings, or invoke the system
> procedure with a command string like "dir > tmp-file" and then if
> you're lucky, you can parse the resulting file.

Thanks. The following works for me (you might need a sensible
definition of read-lines-string here):

(define directory-files (lambda (dir)
  (shell-command (string-append "ls -1 " dir " > /tmp/larceny-directory-files"))
  (let ((result (call-with-input-file "/tmp/larceny-directory-files" read-lines-string)))
    (delete-file "/tmp/larceny-directory-files")
    result)))

> It would not be unreasonable to open a ticket requesting this feature
> to be added to Larceny.  But before doing so, please note the last
> paragraph of: http://www.r6rs.org/formal-comments/comment-124.txt

OK, I will not open a ticket :-)
But I think that directory-files could be a pragmatic extension for
larceny.

Talking about OS specific functions, I need open-input-pipe
which seems to be a little more tricky (for performance reasons, I
cannot use the "file-trick" from above).
This is what I have so far:
(define open-input-pipe (lambda (command)
  (let ((results (process command))) ; format: (input output p-id)
    (car results))))

process is defined in ./lib/Standard/unix.sch but I cannot use it:
> (require 'unix)


Error: Could not locate library: ffi


Greetings
Sven
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : https://lists.ccs.neu.edu/pipermail/larceny-users/attachments/20070130/40645c39/attachment.bin 


More information about the Larceny-users mailing list