SapphireDensetsu / ypsilon

Automatically exported from code.google.com/p/ypsilon
Other
0 stars 0 forks source link

Please provide directory-stream API #124

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
[ Note that this is copy of
  https://bugs.launchpad.net/ikarus/+bug/315804, which got implemented
  as proposed below ]

While Ypsilon provides `directory-list', it doesn't expose the more
primitive {open,read,close}dir() API directly. As a consequence, there
will be problems with large directories, where unnecessary allocation
is forced upon the user even if she would just filter a few items out
of the directory, or just do something to all the files in the
directory (imagine implementing "rm -rf" in Scheme).

Below I've pasted the description of a possible API, taken from "The
Nearly Complete Scheme48 1.3 Reference Manual" [0]:

— procedure: open-directory-stream filename –> dir-stream
— procedure: directory-stream? object –> boolean
— procedure: read-directory-stream dir-stream –> filename or #f
— procedure: close-directory-stream dir-stream –> unspecified

    Directory streams are the low-level interface provided by POSIX to
    enumerate the contents of a directory. Open-directory-stream opens
    a new directory stream that will enumerate all of the files within
    the directory named by filename. Directory-stream? is the disjoint
    type predicate for directory streams. Read-directory-stream
    consumes the next filename from dir-stream and returns it, or
    returns #f if the stream has finished. Note that
    read-directory-stream will return only simple filenames, not full
    pathnames. Close-directory-stream closes dir-stream, removing any
    storage it required in the operating system. Closing an already
    closed directory stream has no effect.

[0] http://mumble.net/~campbell/darcs/s48-refman/

Original issue reported on code.google.com by rott...@gmail.com on 28 Aug 2009 at 6:03