Finding the path to a executable?

Kapps opantm2+spam at gmail.com
Tue Aug 6 23:35:19 PDT 2013


On Wednesday, 7 August 2013 at 05:31:24 UTC, Alan wrote:
> Hello!  This may seem like a simple question, maybe an 
> embarassing question but how would I fetch the absolute path to 
> the directory where my executable is located?  My wording is 
> known to be confusing so I will give an example:
>
> cd ~/projects/program
> dmd Program.d -ofProgram
>
> That executable would be located in /home/alan/projects/program 
> for example.  SO my question is how would I fetch the absolute 
> path to that directory?
>
> Thanks for any help!

The approach that I use is http://pastie.org/8214264 - The 
implementation probably has a fair few flaws though in regards to 
buffer sizes (and only supports Windows / Linux). It's worked in 
the basic situations I've tried though.


More information about the Digitalmars-d mailing list