RejectedSoftware Forums

Sign up

application root path

Hello.
Thanks for great project.
I have question about vibe.d

How to determine application root path?

Re: application root path

On Wed, 24 Apr 2013 15:18:13 GMT, Jack Applegame wrote:

Hello.
Thanks for great project.
I have question about vibe.d

How to determine application root path?

If you mean at run time, this is a bit fiddly (there is no nice abstraction anywhere that I know at least):
http://stackoverflow.com/questions/1023306/finding-current-executables-path-without-proc-self-exe

It would probably be a good idea to add such a function to Phobos at some point.

Usually, to avoid that, I just assume that the current working directory is the same as the executable directory at startup and store that as the application root (or possibly the parent directory).

Re: application root path

On Fri, 26 Apr 2013 05:41:00 GMT, Sönke Ludwig wrote:

Usually, to avoid that, I just assume that the current working directory is the same as the executable directory at startup and store that as the application root (or possibly the parent directory).

Yes! Good idea. DUB stores application binary somewhere in temporary directory, and it's useless to determine executable path. Thanks.

Re: application root path

On Fri, 26 Apr 2013 05:41:00 GMT
"Sönke Ludwig" sludwig@rejectedsoftware.com wrote:

On Wed, 24 Apr 2013 15:18:13 GMT, Jack Applegame wrote:

Hello.
Thanks for great project.
I have question about vibe.d

How to determine application root path?

If you mean at run time, this is a bit fiddly (there is no nice
abstraction anywhere that I know at least)

You can use this:

https://bitbucket.org/Abscissa/semitwistdtools/src/c278c4620638629faa396a2d29e4b5034abf874d/src/semitwist/util/io.d?at=master#cl-168

(It uses some special imports at the top of that file.)

Should work for (at least) Win/Lin/OSX.