added pathlist-closure to file.ss
svn: r3160
This commit is contained in:
parent
ce0c03c60f
commit
436c36cc1e
|
@ -20,7 +20,8 @@
|
||||||
call-with-output-file*
|
call-with-output-file*
|
||||||
|
|
||||||
fold-files
|
fold-files
|
||||||
find-files)
|
find-files
|
||||||
|
pathlist-closure)
|
||||||
|
|
||||||
(require "list.ss"
|
(require "list.ss"
|
||||||
"etc.ss")
|
"etc.ss")
|
||||||
|
@ -496,4 +497,25 @@
|
||||||
(reverse! (fold-files (lambda (path kind acc)
|
(reverse! (fold-files (lambda (path kind acc)
|
||||||
(if (f path) (cons path acc) acc))
|
(if (f path) (cons path acc) acc))
|
||||||
null
|
null
|
||||||
path)))))
|
path))))
|
||||||
|
|
||||||
|
(define (pathlist-closure paths)
|
||||||
|
(let loop ([paths (map (lambda (p) (simplify-path p #f)) paths)]
|
||||||
|
[r '()])
|
||||||
|
(if (null? paths)
|
||||||
|
(reverse! r)
|
||||||
|
(let loop2 ([path (car paths)]
|
||||||
|
[new (cond [(file-exists? (car paths))
|
||||||
|
(list (car paths))]
|
||||||
|
[(directory-exists? (car paths))
|
||||||
|
(find-files void (car paths))]
|
||||||
|
[else (error 'pathlist-closure
|
||||||
|
"file/directory not found: ~a"
|
||||||
|
(car paths))])])
|
||||||
|
(let-values ([(base name dir?) (split-path path)])
|
||||||
|
(if (path? base)
|
||||||
|
(loop2 base (if (or (member base r) (member base paths))
|
||||||
|
new (cons base new)))
|
||||||
|
(loop (cdr paths) (append! (reverse! new) r))))))))
|
||||||
|
|
||||||
|
)
|
||||||
|
|
|
@ -262,21 +262,7 @@
|
||||||
(provide zip)
|
(provide zip)
|
||||||
(define (zip zip-file . paths)
|
(define (zip zip-file . paths)
|
||||||
(when (null? paths) (error 'zip "no paths specified"))
|
(when (null? paths) (error 'zip "no paths specified"))
|
||||||
(let loop ([paths (map (lambda (p) (simplify-path p #f)) paths)]
|
(with-output-to-file zip-file
|
||||||
[r '()])
|
(lambda () (zip->output (pathlist-closure paths)))))
|
||||||
(if (null? paths)
|
|
||||||
(with-output-to-file zip-file (lambda () (zip->output (reverse! r))))
|
|
||||||
(let loop2 ([path (car paths)]
|
|
||||||
[new (cond [(file-exists? (car paths))
|
|
||||||
(list (car paths))]
|
|
||||||
[(directory-exists? (car paths))
|
|
||||||
(find-files void (car paths))]
|
|
||||||
[else (error 'zip "file/directory not found: ~a"
|
|
||||||
(car paths))])])
|
|
||||||
(let-values ([(base name dir?) (split-path path)])
|
|
||||||
(if (path? base)
|
|
||||||
(loop2 base (if (or (member base r) (member base paths))
|
|
||||||
new (cons base new)))
|
|
||||||
(loop (cdr paths) (append! (reverse! new) r))))))))
|
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user