17
18
19
20
21
22
23
|
(let ((new (string-append curr part)))
(cond
((and (directory? curr)(file-read-access? curr))
(glob new))
((member part '("." ".." "/")) new)
(else '()))))
result)))))))))
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
(let ((new (string-append curr part)))
(cond
((and (directory? curr)(file-read-access? curr))
(glob new))
((member part '("." ".." "/")) new)
(else '()))))
result)))))))))
;; alternative implementation
(define (path-glob pattern)
(let ((parts (string-split pattern "/" '())))
(if (null? parts)
'()
(glob-expand (car parts) (cdr parts))
)))
(define (glob-expand pattern #!optional (rest '()))
(let ((result '()) (expanded (glob pattern)))
(apply append result (cond
((null? expanded) (list '()))
((null? rest) (list expanded))
(else (map (lambda (x) (if (directory? x) (glob-expand (conc x "/" (car rest)) (cdr rest)) '())) expanded))
))))
|