From 1c114c3e946814edf61d140015679f8d36f12fcf Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Fri, 16 Apr 2010 14:43:41 -0400 Subject: [PATCH] made the file work when the cwd is not the files directory --- collects/teachpack/2htdp/scribblings/image-gen.ss | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/collects/teachpack/2htdp/scribblings/image-gen.ss b/collects/teachpack/2htdp/scribblings/image-gen.ss index 145ea91943..708b6c0ac4 100644 --- a/collects/teachpack/2htdp/scribblings/image-gen.ss +++ b/collects/teachpack/2htdp/scribblings/image-gen.ss @@ -5,8 +5,12 @@ (require 2htdp/image lang/posn + scheme/runtime-path (only-in 2htdp/private/image-more save-image)) +(define-runtime-path image.scrbl "image.scrbl") +(define-runtime-path img "img") + (define-namespace-anchor anchor) (define ns (namespace-anchor->namespace anchor)) (define expressions @@ -16,7 +20,7 @@ (thread (λ () (parameterize ([current-output-port out]) - (dynamic-require "image.scrbl" #f)) + (dynamic-require image.scrbl #f)) (close-output-port out))) (let loop () (let ([exp (read in)]) @@ -42,7 +46,9 @@ [(image? result) (let ([fn (exp->filename exp)]) (set! mapping (cons `(list ',exp 'image ,fn) mapping)) - (save-image result (build-path "img" fn)))] + (let ([pth (build-path img fn)]) + (unless (save-image result pth) + (fprintf (current-error-port) "failed to save ~s\n" pth))))] [else (unless (equal? result (read/write result)) (error 'handle-image "expression ~s produced ~s, which I can't write"