set eol-style
svn: r2757
This commit is contained in:
parent
7797db25a9
commit
4bf87ba029
|
@ -1,39 +1,39 @@
|
||||||
|
|
||||||
(module windlldir mzscheme
|
(module windlldir mzscheme
|
||||||
(require (lib "port.ss"))
|
(require (lib "port.ss"))
|
||||||
|
|
||||||
(provide update-dll-dir
|
(provide update-dll-dir
|
||||||
get-current-dll-dir)
|
get-current-dll-dir)
|
||||||
|
|
||||||
(define label "dLl dIRECTORy:")
|
(define label "dLl dIRECTORy:")
|
||||||
(define max-dir-len 512)
|
(define max-dir-len 512)
|
||||||
|
|
||||||
(define (update-dll-dir dest path)
|
(define (update-dll-dir dest path)
|
||||||
(let ([path-bytes (if (eq? path #t)
|
(let ([path-bytes (if (eq? path #t)
|
||||||
#"<system>"
|
#"<system>"
|
||||||
(if (path? path)
|
(if (path? path)
|
||||||
(path->bytes path)
|
(path->bytes path)
|
||||||
(string->bytes/locale path)))])
|
(string->bytes/locale path)))])
|
||||||
(unless ((bytes-length path-bytes) . <= . max-dir-len)
|
(unless ((bytes-length path-bytes) . <= . max-dir-len)
|
||||||
(error 'update-dll-dir "path too long: ~e" path))
|
(error 'update-dll-dir "path too long: ~e" path))
|
||||||
(let ([m (with-input-from-file dest
|
(let ([m (with-input-from-file dest
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(regexp-match-positions label (current-input-port))))])
|
(regexp-match-positions label (current-input-port))))])
|
||||||
(unless m
|
(unless m
|
||||||
(error 'update-ddl-dir "cannot find DLL path in file: ~e" dest))
|
(error 'update-ddl-dir "cannot find DLL path in file: ~e" dest))
|
||||||
(with-output-to-file dest
|
(with-output-to-file dest
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(file-position (current-output-port) (cdar m))
|
(file-position (current-output-port) (cdar m))
|
||||||
(write-bytes path-bytes)
|
(write-bytes path-bytes)
|
||||||
(write-byte 0))
|
(write-byte 0))
|
||||||
'update))))
|
'update))))
|
||||||
|
|
||||||
|
|
||||||
(define (get-current-dll-dir dest)
|
(define (get-current-dll-dir dest)
|
||||||
(with-input-from-file dest
|
(with-input-from-file dest
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(unless (regexp-match label (current-input-port))
|
(unless (regexp-match label (current-input-port))
|
||||||
(error 'get-current-dll-dir "cannot find DLL path in file: ~e" dest))
|
(error 'get-current-dll-dir "cannot find DLL path in file: ~e" dest))
|
||||||
(let ([p (make-limited-input-port (current-input-port) max-dir-len)])
|
(let ([p (make-limited-input-port (current-input-port) max-dir-len)])
|
||||||
(let ([m (regexp-match #rx#"[^\0]*" p)])
|
(let ([m (regexp-match #rx#"[^\0]*" p)])
|
||||||
(bytes->path (car m))))))))
|
(bytes->path (car m))))))))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user