more minorities
svn: r16466
This commit is contained in:
parent
f0f9e995d6
commit
6d2756c562
|
@ -290,10 +290,11 @@
|
||||||
|
|
||||||
;; fold-files : (pathname sym alpha -> alpha) alpha pathname/#f -> alpha
|
;; fold-files : (pathname sym alpha -> alpha) alpha pathname/#f -> alpha
|
||||||
(define (fold-files f init [path #f] [follow-links? #t])
|
(define (fold-files f init [path #f] [follow-links? #t])
|
||||||
(define-syntax-rule (discard-second-val e)
|
(define-syntax-rule (keep-fst e)
|
||||||
(call-with-values (λ () e) (λ (acc [extra #f]) acc)))
|
(call-with-values (lambda () e) (case-lambda [(v) v] [(v _) v])))
|
||||||
(define (do-path path acc)
|
(define (do-path path acc)
|
||||||
(cond [(and (not follow-links?) (link-exists? path)) (discard-second-val (f path 'link acc))]
|
(cond [(and (not follow-links?) (link-exists? path))
|
||||||
|
(keep-fst (f path 'link acc))]
|
||||||
[(directory-exists? path)
|
[(directory-exists? path)
|
||||||
(call-with-values (lambda () (f path 'dir acc))
|
(call-with-values (lambda () (f path 'dir acc))
|
||||||
(lambda (acc [descend? #t])
|
(lambda (acc [descend? #t])
|
||||||
|
@ -302,8 +303,8 @@
|
||||||
(sorted-dirlist path))
|
(sorted-dirlist path))
|
||||||
acc)
|
acc)
|
||||||
acc)))]
|
acc)))]
|
||||||
[(file-exists? path) (discard-second-val (f path 'file acc))]
|
[(file-exists? path) (keep-fst (f path 'file acc))]
|
||||||
[(link-exists? path) (discard-second-val (f path 'link acc))] ; dangling links
|
[(link-exists? path) (keep-fst (f path 'link acc))] ; dangling links
|
||||||
[else (error 'fold-files "path disappeared: ~e" path)]))
|
[else (error 'fold-files "path disappeared: ~e" path)]))
|
||||||
(define (do-paths paths acc)
|
(define (do-paths paths acc)
|
||||||
(cond [(null? paths) acc]
|
(cond [(null? paths) acc]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user