removed bogus type lines, made find-files reverse its result so directories precede files which is usually desirable

svn: r3087
This commit is contained in:
Eli Barzilay 2006-05-27 15:26:24 +00:00
parent 058f6c3530
commit 7523be44de

View File

@ -473,38 +473,27 @@
(define fold-files
(opt-lambda (f init [path #f] [follow-links? #t])
;; traverse-dir : string[directory] (listof string[file/directory]) -> (listof string[file/directory])
(define (traverse-dir dir base acc)
(let loop ([subs (directory-list dir)]
[acc acc])
(cond
[(null? subs) acc]
[else (loop (cdr subs)
(let ([path (if base
(build-path base (car subs))
(car subs))])
(traverse-file/dir path path acc)))])))
(let loop ([subs (directory-list dir)] [acc acc])
(cond [(null? subs) acc]
[else (loop (cdr subs)
(let ([path (if base
(build-path base (car subs))
(car subs))])
(traverse-file/dir path path acc)))])))
;; traverse-file/dir : string[file/directory] (listof string[file/directory]) -> (listof string[file/directory])
(define (traverse-file/dir file/dir base acc)
(cond
[(and (not follow-links?) (link-exists? file/dir))
(f file/dir 'link acc)]
[(directory-exists? file/dir)
(traverse-dir file/dir base (if base
(f file/dir 'dir acc)
acc))]
[else (f file/dir 'file acc)]))
(traverse-file/dir (or path (current-directory))
path
init)))
(cond [(and (not follow-links?) (link-exists? file/dir))
(f file/dir 'link acc)]
[(directory-exists? file/dir)
(traverse-dir file/dir base (if base (f file/dir 'dir acc) acc))]
[else (f file/dir 'file acc)]))
(define find-files
(traverse-file/dir (or path (current-directory)) path init)))
(define find-files
(opt-lambda (f [path #f])
(fold-files (lambda (path kind acc)
(if (f path)
(cons path acc)
acc))
null
path))))
(reverse! (fold-files (lambda (path kind acc)
(if (f path) (cons path acc) acc))
null
path)))))