[racket] define-runtime-path and raco distrib

From: Kieron Hardy (kieron.hardy at gmail.com)
Date: Mon Jul 16 17:13:45 EDT 2012

Hi all,

How do I get a run-time path in the executable created by 'raco distrib',
that is the same, relative to the directory containing the source racket
code and the executable created by 'raco exe'?

When I execute the following code (modified from the documentation), I
observe that the directory for the data file for the executable generated
by 'raco distrib':


is very different from the directory used by both the source module and the
executable generated by 'raco exe':

   read-data: data-file:"...\test-path\data.txt".

How do I make the ".\lib\plt\test-path\exts\ert\...\test-path\" go away and
have the data file be packaged in the same directory as the executable?

I need the program to access a data file that I expect an end-user to
modify, and the additional subdirs between where the program and data file
are a bit of a problem. Perhaps I should be using some other approach?

Thanks in advanced for any advice.




#lang racket

; Access a file "data.txt" at run-time that is originally
; located in the same directory as the module source file:
(define-runtime-path data-file "data.txt")
(define (read-data)
  (with-input-from-file data-file
    (lambda ()
      (read-bytes (file-size data-file)))))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120716/5d39276f/attachment.html>

Posted on the users mailing list.