full path to source file __FILE__

Jonathan Marler via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 22 12:29:51 PDT 2016


On Friday, 22 July 2016 at 19:23:30 UTC, Steven Schveighoffer 
wrote:
> On 7/22/16 2:43 PM, Kagamin wrote:
>> On Friday, 22 July 2016 at 13:50:55 UTC, Jonathan Marler wrote:
>>> shell/anypath> rdmd /somedir/clean.d
>>> Removing /somedir/build...
>>
>> So for command rdmd /somedir/clean.d what __FILE__ contains? 
>> LDC tells
>> me the same path as specified on the command line, and that is 
>> specified
>> relative to current directory, where the compiler is called, so
>> absolutePath(__FILE__) should give the right result.
>
> The issue which is not being expressed completely by Jonathan, 
> is that rdmd caches the build.
>
> So if I run the script from one directory, then cd elsewhere, 
> it has the same __FILE__ as before, but the cwd has moved. So 
> it won't work.
>
> I had assumed rdmd would rebuild, but it doesn't.
>
> -Steve

Thanks for pointing this out, somehow I overlooked this use case.


More information about the Digitalmars-d-learn mailing list