remove internal sorted-dirlist function

The result of `directory-list` is now sorted by default, so the
extra function is not needed.
This commit is contained in:
Matthew Flatt 2014-10-27 13:58:09 -06:00
parent 9291726482
commit 35a762b556

View File

@ -45,14 +45,6 @@
(require "private/portlines.rkt") (require "private/portlines.rkt")
;; utility: sorted dirlist so functions are deterministic
(define (sorted-dirlist [dir (current-directory)])
(let* ([ps (directory-list dir)]
[ps (map (lambda (p) (cons (path->string p) p)) ps)]
[ps (sort ps (lambda (p1 p2) (string<? (car p1) (car p2))))]
[ps (map cdr ps)])
ps))
(define (delete-directory/files path (define (delete-directory/files path
#:must-exist? [must-exist? #t]) #:must-exist? [must-exist? #t])
(unless (path-string? path) (unless (path-string? path)
@ -63,7 +55,7 @@
(delete-file path)] (delete-file path)]
[(directory-exists? path) [(directory-exists? path)
(for-each (lambda (e) (loop (build-path path e))) (for-each (lambda (e) (loop (build-path path e)))
(sorted-dirlist path)) (directory-list path))
(delete-directory path)] (delete-directory path)]
[else [else
(when must-exist? (when must-exist?
@ -91,7 +83,7 @@
(for-each (lambda (e) (for-each (lambda (e)
(loop (build-path src e) (loop (build-path src e)
(build-path dest e))) (build-path dest e)))
(sorted-dirlist src))] (directory-list src))]
[else (raise-not-a-file-or-directory 'copy-directory/files src)]))) [else (raise-not-a-file-or-directory 'copy-directory/files src)])))
(define (make-directory* dir) (define (make-directory* dir)
@ -625,7 +617,7 @@
(lambda (acc [descend? #t]) (lambda (acc [descend? #t])
(if descend? (if descend?
(do-paths (map (lambda (p) (build-path path p)) (do-paths (map (lambda (p) (build-path path p))
(sorted-dirlist path)) (directory-list path))
acc) acc)
acc)))] acc)))]
[(file-exists? path) (keep-fst (f path 'file acc))] [(file-exists? path) (keep-fst (f path 'file acc))]
@ -635,7 +627,7 @@
(cond [(null? paths) acc] (cond [(null? paths) acc]
[else (do-paths (cdr paths) (do-path (car paths) acc))])) [else (do-paths (cdr paths) (do-path (car paths) acc))]))
(define (to-path s) (if (path? s) s (string->path s))) (define (to-path s) (if (path? s) s (string->path s)))
(if path (do-path (to-path path) init) (do-paths (sorted-dirlist) init))) (if path (do-path (to-path path) init) (do-paths (directory-list) init)))
(define (find-files f [path #f] #:follow-links? [follow-links? #t]) (define (find-files f [path #f] #:follow-links? [follow-links? #t])
(reverse (reverse