full path to source file __FILE__

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 22 06:30:10 PDT 2016


On 7/22/16 3:47 AM, Jonathan Marler wrote:
>> What's wrong with __FILE__.dirName ?
>
> It's kinda weird, sometimes I've noticed that the __FILE__ keyword is an
> absolute path, and sometimes it isn't.

If you combine it with current working directory, this should give you 
the full path.

Looks like std.path gives you a mechanism, I think this should work:

import std.path;
auto p = __FILE__.absolutePath;

http://dlang.org/phobos/std_path.html#.absolutePath

-Steve



More information about the Digitalmars-d-learn mailing list