On Mon, Jul 06, 2015 at 02:50:36PM -0700, Russ Abbott wrote: > I installed Racket in a directory for which I have access. Yet when I > attempted to run the example code on the Racket Home page: > > (for ([path (in-directory)] > #:when (regexp-match? #rx"[.]rkt$" path)) > (printf "source file: ~a\n" path)) > > I got this error message. > > Racket\collects\racket\private\for.rkt:1973:2: directory-list: could not open > directory > path: C:\Users\facuser\AppData\Local\Application Data > system error: Access is denied.; errno=5
As coded with no arguments, (in-directory) produces a sequence that will traverse all files and subdirectories (of the current directory) recursively [1]. On Windows that runs into permissions problems even in one's own home directory. The second argument to in-directory can control the recursion, but to avoid recursion entirely use directory-list [2] instead: (for ([path (directory-list)] #:when (regexp-match? #rx"[.]rkt$" path)) (printf "source file: ~a\n" path)) As a side note, I tried using file-or-directory-permissions [3] to avoid recursing into directories with no read or execute permission, but it turns out some directories are inaccessible on Windows even though file-or-directory-permissions returns '(execute write read). I don't know enough about Windows permissions to know whether that is expected. [1] http://docs.racket-lang.org/reference/sequences.html#(def._((lib._racket/private/base..rkt)._in-directory)) [2] http://docs.racket-lang.org/reference/Filesystem.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._directory-list%29%29 [3] http://docs.racket-lang.org/reference/Filesystem.html#%28def._%28%28quote._~23~25kernel%29._file-or-directory-permissions%29%29 David -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.