[racket-dev] A function for checking if a library path exists

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Apr 23 18:31:30 EDT 2014

I think you're looking for `resolve-module-path`.

At Wed, 23 Apr 2014 17:41:19 -0400, Sam Tobin-Hochstadt wrote:
> I'd like to have a function that takes a collection path, as can be
> given to `lib`, and gives me back the file name.  What's the best way
> to do this?
> It would seem like `collection-file-path` is the obvious solution, but
> that requires me to parse `racket/list` into "racket" and "list.rkt".
> The other alternative is, I think:
> (define (f x)
>   (define rmp ((current-module-name-resolver) x #f #f #f))
>   (define p (resolved-module-path-name rmp))
>   (and (file-exists? p) p))
> Is this correct? Is there a simpler way to write it?
> Sam
> _________________________
>   Racket Developers list:
>   http://lists.racket-lang.org/dev

Posted on the dev mailing list.