Heya, On Sat 10 Dec 2011 15:52, l...@gnu.org (Ludovic Courtès) writes:
> Andy Wingo <wi...@pobox.com> skribis: > >> On Tue 30 Aug 2011 18:06, l...@gnu.org (Ludovic Courtès) writes: >> >>> I was actually planning to push ‘file-system-fold’, a functional >>> alternative to ‘ftw’, which would be along the lines of this (from >>> <http://git.savannah.gnu.org/cgit/libchop.git/tree/utils/chop-backup#n46>): >>> >>> (define (file-system-fold enter? leaf down up skip init file-name) >>> "Traverse the directory at FILE-NAME, recursively. Enter >>> sub-directories >>> only when (ENTER? PATH STAT RESULT) returns true. When a sub-directory is >>> entered, call (DOWN PATH STAT RESULT), where PATH is the path of the >>> sub-directory and STAT the result of (lstat PATH); when it is left, call >>> (UP >>> PATH STAT RESULT). For each file in a directory, call (LEAF PATH STAT >>> RESULT). Return the result of these successive applications. When ENTER? >>> returns no, call (SKIP PATH STAT RESULT)." >>> >>> ...) >> >> I see that you haven't pushed this yet. Want to do so? > > Yes, I’m looking into this now. > > I was planning to make it part of (ice-9 ftw); WDYT? Sounds fine to me. I didn't take a close look at the implementation, but the idea of the function sounded sane to me. >> I would be happy with a `scandir' implementation on top of this >> interface. > > Yes. The mixture of concerns in that function is not brilliant, but > OTOH it’s probably good to have a function people are familiar with. Yeah, I have the same thoughts. OTOH, if file-system-fold goes into (ice-9 ftw), where would a `scandir' go? There also? I guess that's OK. Just thinking out loud :) Happy hacking, Andy -- http://wingolog.org/