On Mon, 23 Dec 2013 16:44:03 -0500 Matthias Felleisen <matth...@ccs.neu.edu> wrote:
> > Sadly, I think you may have to re-implement in-directory (with a > recursive traversal like the one in for.rkt) but use > file-or-directory-permission before you try to go into a > subdirectory. -- Matthias > > > Yep, I did it like this: (define (can-read-directory? d) (if (member 'read (file-or-directory-permissions d)) #t (begin (display "Permission denied for ") (displayln d) #f))) and in in-directory: (when (and (directory-exists? fp) (can-read-directory? fp)) (loop fp p))))) Perhaps not the smartest way but it works fine now: I think in-directory should be fixed in the long run. -- Manfred > On Dec 23, 2013, at 4:09 PM, Manfred Lotz > <manfred.l...@arcor.de> wrote: > > > I had a look into collects/racket/private/for.rkt where > > in-directory is defined. > > > > I have to admit that I don't understand much of the stuff as this > > is a level of Racket I haven't yet mastered. > > > > Nevertheless, there is > > (when (directory-exists? fp) > > (loop fp p))))) > > > > Here it should be checked if there is permission to read fp. Not > > quite sure what is the best way to handle it. Issue an error > > message and continue, or let the issuer of in-directory decide what > > to do. > > > > In my case I copied the stuff into my own source, renamed it, > > checked permissions and issue a message if there is no permission > > to read and continue. Seems to be the solution for me for the time > > being. > > > > > > > > -- > > Manfred > > > > > > > > On Mon, 23 Dec 2013 15:20:32 -0500 > > Matthias Felleisen > > <matth...@ccs.neu.edu> wrote: > > > >> > >> For that, you will need to wrap the whole loop because > >> (in-directory ...) fails, and no, I don't know how to resume this > >> optimized loop: > >> > >> #lang racket ;; foo.rkt > >> > >> (define start-dir ".") > >> > >> ;; > >> (with-handlers (((lambda (x) #t) (lambda (e) (log-warning > >> "in-directory failed")))) (for ([f (in-directory start-dir)] #:when > >> (regexp-match #rx"\\.rkt" f)) (with-handlers ((exn:fail:contract? > >> (lambda (e) (log-warning (exn-message e)))) (exn? displayln)) > >> (displayln (path->string f))))) > >> > >> > >> > >> On Dec 23, 2013, at 3:06 PM, Manfred Lotz > >> <manfred.l...@arcor.de> wrote: > >> > >>> #lang racket ;; foo.rkt > >>> > >>> (define start-dir "/tmp/testdir") > >>> > >>> (for ([f (in-directory start-dir)] #:when (regexp-match > >>> #rx"\\.rkt" f)) (with-handlers ((exn:fail:contract? (lambda (e) > >>> (log-warning (exn-message e))))) > >>> (displayln (path->string f)))) > >> > >> > >> ____________________ > >> Racket Users list: > >> http://lists.racket-lang.org/users > >> > > > > > > > > ____________________ > > Racket Users list: > > http://lists.racket-lang.org/users > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > ____________________ Racket Users list: http://lists.racket-lang.org/users