"Jeff Clites" <[EMAIL PROTECTED]> wrote:
> On Apr 14, 2004, at 10:20 PM, Jarkko Hietaniemi wrote:
>
> > Finding stuff relative to the executable/DLL would be coolest scheme,
> > but that is admittedly somewhat tricky to get working cross-platform.
>
> Excellent idea. Pretty much every single resource in Cocoa applications
> and frameworks on Mac OS X is located using a scheme such as this, and
> I believe it all used to work correctly for OpenStep applications on
> Windows, so there's a good chance it could be made to work.
>
> For Unix platforms at least, you should be able to do this:
>
> executablePath = isAbsolute($0) ? dirname($0) : cwd().dirname($0)
>
> (to mix a bunch of syntaxes)
>
> during initialization before you've had a chance to chdir, and store
> that away on the interpreter struct. That should work unless you've
> gone out of your way to execute parrot with argv[0] set to something
> "fake". I don't know what you'd do on Windows, but there must be
> something.
>
Strangely enough, I'm in the middle of putting something like this in place
for another project...  On Win32 you do:-

GetModuleFileName(NULL, buffer, buffer_size)

Passing NULL in as the first parameter returns the path to the executable
the currently executing process (e.g. Parrot in our case) was created from.
You then just need to chop off the executable name to find your path.

Jonathan


Reply via email to