Put cwd in a record to be able to define a resumer that initializes to

process-cwd.
This commit is contained in:
marting 2000-07-11 12:29:35 +00:00
parent 8c7c9c2006
commit d130f23f0d
1 changed files with 13 additions and 6 deletions

View File

@ -292,10 +292,10 @@
(define-record-resumer type/cache (define-record-resumer type/cache
(lambda (cache) (lambda (cache)
(set-cache:cwd cache ""))) ; set the cache to an impossible filename. (set-cache:cwd cache (process-cwd)))) ; set the cache to an impossible filename.
(define *unix-cwd* (define *unix-cwd*
(make-cache "")) ; Initialise the cache to an impossible filename. (make-cache (process-cwd))) ; Initialise the cache to an impossible filename.
(define (unix-cwd) (define (unix-cwd)
(cache:cwd *unix-cwd*)) (cache:cwd *unix-cwd*))
@ -325,12 +325,19 @@
result)))) result))))
;;; The thread-specific CWD: A fluid ;;; The thread-specific CWD: A fluid
(define $cwd (make-fluid (process-cwd))) (define-record state
cwd)
(define (cwd) (fluid $cwd)) (define-record-resumer type/state
(define (set-cwd! dir) (set-fluid! $cwd dir)) (lambda (state)
(set-state:cwd state (make-fluid (process-cwd)))))
(define $cwd (make-state (make-fluid (process-cwd))))
(define (cwd) (fluid (state:cwd $cwd)))
(define (set-cwd! dir) (set-fluid! (state:cwd $cwd) dir))
(define (let-cwd dir thunk) (define (let-cwd dir thunk)
(let-fluid $cwd dir thunk)) (let-fluid (state:cwd $cwd) dir thunk))
(define (with-cwd* dir thunk) (define (with-cwd* dir thunk)
(let ((changed-dir #f)) (let ((changed-dir #f))