From 7422d62fa40e7da3dd28f9565ec627f550dc6296 Mon Sep 17 00:00:00 2001 From: Danny Yoo Date: Fri, 12 Aug 2011 17:22:33 -0400 Subject: [PATCH] getting resources to work --- examples/using-resources.rkt | 12 ++++++++---- resource/racket-impl.rkt | 4 ++-- whalesong.rkt | 4 ++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/examples/using-resources.rkt b/examples/using-resources.rkt index 28096bb..77dd074 100644 --- a/examples/using-resources.rkt +++ b/examples/using-resources.rkt @@ -1,10 +1,14 @@ #lang planet dyoo/whalesong -(require (planet dyoo/whalesong/resource)) +(require (planet dyoo/whalesong/resource) + (planet dyoo/whalesong/image)) + (define-resource whale-resource "images/humpback.jpg") -#;(define whale-image - (image-url - (resource->url whale-resource))) +(define whale-image + (image-url + (resource->url whale-resource))) whale-resource +whale-image +whale-image \ No newline at end of file diff --git a/resource/racket-impl.rkt b/resource/racket-impl.rkt index 51a5d51..6f2dee9 100644 --- a/resource/racket-impl.rkt +++ b/resource/racket-impl.rkt @@ -5,6 +5,6 @@ net/url) - +;; resource->url: resource -> string (define (resource->url r) - (path->url (resource-path r))) + (url->string (path->url (resource-path r)))) diff --git a/whalesong.rkt b/whalesong.rkt index 68ef8b8..1375bd9 100755 --- a/whalesong.rkt +++ b/whalesong.rkt @@ -120,6 +120,10 @@ (lambda (r) (make-directory* (current-resource-dir)) (log-info (format "Writing resource ~s" (resource-path r))) + (when (file-exists? (build-path (current-resource-dir) + (resource-key r))) + (delete-file (build-path (current-resource-dir) + (resource-key r)))) (copy-file (resource-path r) (build-path (current-resource-dir) (resource-key r))))])