guard call to file-or-directory-permissions

related to PR 13359
also, Rackety
This commit is contained in:
Robby Findler 2013-01-05 11:26:10 -06:00
parent e66cd6f9c7
commit 0c76c692ac

View File

@ -1955,22 +1955,25 @@
(define read-write? #t) (define read-write? #t)
(define/public (get-read-write?) read-write?) (define/public (get-read-write?) read-write?)
(define/private (check-lock) (define/private (check-lock)
(let* ([filename (get-filename)] (define filename (get-filename))
[can-edit? (if (and filename (define can-edit?
(file-exists? filename)) (if (and filename
(and (member 'write (file-or-directory-permissions filename)) (file-exists? filename))
#t) (and (member 'write
#t)]) (with-handlers ([exn:fail:filesystem? (λ (x) '())])
(set! read-write? can-edit?))) (file-or-directory-permissions filename)))
#t)
#t))
(set! read-write? can-edit?))
(define/public (while-unlocked t) (define/public (while-unlocked t)
(let ([unlocked? 'unint]) (define unlocked? 'unint)
(dynamic-wind (dynamic-wind
(λ () (λ ()
(set! unlocked? read-write?) (set! unlocked? read-write?)
(set! read-write? #t)) (set! read-write? #t))
(λ () (t)) (λ () (t))
(λ () (set! read-write? unlocked?))))) (λ () (set! read-write? unlocked?))))
(define/augment (can-insert? x y) (define/augment (can-insert? x y)
(and read-write? (inner #t can-insert? x y))) (and read-write? (inner #t can-insert? x y)))