[plt-scheme] Executing modules current dir

From: YC (yinso.chen at gmail.com)
Date: Wed Sep 30 15:28:30 EDT 2009

On Wed, Sep 30, 2009 at 6:13 AM, Jakub Piotr Cłapa <jpc-ml at zenburn.net>wrote:

> On 09-09-30 14:39, Stephen De Gabrielle wrote:
>
>> Hi, I want to include a binary in a module, that I call with (system
>> command), except I don't know to reference it, as current-directory is
>> the users home dir&  none of the others that I found seem to do the
>> job. The idea is to package win, osx and Linux binaries in the module.
>>
>
> Perhaps define-runtime-path would help?
>
> This expects the binaries in the same directory as the module. It also
> works with Create Executable:
> (define-runtime-path *sepack-path* (case (system-type)
>                                     [(macosx) "./sepack"]
>                                     [(windows) "sepack.exe"]))
>

Another way is to use this-expression-source-directory in mzlib/etc

(require mzlib/etc)
(define path (build-path (this-expression-source-directory) ...))

Also should you prefer - you can make use of bzlib/os, which helps simplify
the writing of the system-type case statements:

(require (planet bzlib/os))
(define-runtime-path path (+:windows "sepack.exe" "sepack")) ;; windows =>
sepack.exe; else => sepack

Cheers,
yc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090930/d2447b33/attachment.html>

Posted on the users mailing list.