Why file.exists of relative path on Linux always return false?

Edwin van Leeuwen via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Feb 29 07:01:52 PST 2016


On Monday, 29 February 2016 at 14:58:46 UTC, Alex Parrill wrote:
> On Monday, 29 February 2016 at 14:50:51 UTC, Suliman wrote:
>> I am trying to check relative path on Linux for exists.
>>
>> string mypath = "~/Documents/imgs";
>
> ~ is expanded by your shell. It is not a relative path, and 
> system calls do not recognize it (same with environmental 
> variables).

D can expand tilde with expandTilde:

import std.path : expandTilde;
string mypath = expandTilde("~/Documents/imgs");




More information about the Digitalmars-d-learn mailing list