diff --git a/racket/src/io/Makefile b/racket/src/io/Makefile index 8a27e93bbf..35f3fa09d2 100644 --- a/racket/src/io/Makefile +++ b/racket/src/io/Makefile @@ -23,6 +23,7 @@ GLOBALS = --no-global \ ++global-ok "string->number?" \ ++global-ok "printable-regexp?" \ ++global-ok do-global-print \ + ++global-ok simplify-path/dl \ ++global-ok exec-file \ ++global-ok run-file \ ++global-ok collects-dir \ diff --git a/racket/src/io/file/main.rkt b/racket/src/io/file/main.rkt index 075146292b..88285fe3cd 100644 --- a/racket/src/io/file/main.rkt +++ b/racket/src/io/file/main.rkt @@ -36,7 +36,9 @@ filesystem-root-list ;; For the expander to register `maybe-raise-missing-module`: - set-maybe-raise-missing-module!) + set-maybe-raise-missing-module! + ;; To resolve a cycle with the definition of `simplify-path` + set-simplify-path-for-directory-list!) (define/who (directory-exists? p) (check who path-string? p) @@ -65,9 +67,18 @@ "") (host-> host-path))))) +(define simplify-path/dl (lambda (p) p)) +(define (set-simplify-path-for-directory-list! proc) + (set! simplify-path/dl proc)) + (define/who (directory-list [p (current-directory)]) (check who path-string? p) - (define host-path (->host p who '(read))) + (define host-path/initial (->host p who '(read))) + (define host-path (case (system-type) + [(windows) + ;; Need to avoid "." and "..", so simplify + (->host (simplify-path/dl (host-> host-path/initial)) #f '())] + [else host-path/initial])) (atomically (call-with-resource (rktio_directory_list_start rktio host-path) diff --git a/racket/src/io/path/simplify.rkt b/racket/src/io/path/simplify.rkt index 1db7134f24..99b5aa46a2 100644 --- a/racket/src/io/path/simplify.rkt +++ b/racket/src/io/path/simplify.rkt @@ -106,6 +106,8 @@ (path->directory-path simpler-p) simpler-p)])])) +(void (set-simplify-path-for-directory-list! simplify-path)) + ;; ---------------------------------------- ;; Quick check for whether the path is already simple: