Re: dirEntries returns relative, not absolute paths

2018-02-06 Thread Timothee Cour via Digitalmars-d-learn
https://github.com/dlang/phobos/pull/6133

On Tue, Feb 6, 2018 at 1:40 PM, Jonathan M Davis via
Digitalmars-d-learn  wrote:
> On Tuesday, February 06, 2018 18:58:43 number via Digitalmars-d-learn wrote:
>> https://dlang.org/phobos/std_file.html#dirEntries
>>
>> >> The name of each iterated directory entry contains the
>> >> absolute path.
>>
>> it seems to be absolute only if the specified path is absolute,
>> or always relative to the parent dir of the specified path.
>
> Then the docs need to be fixed.
>
> - Jonathan M Davis
>


Re: dirEntries returns relative, not absolute paths

2018-02-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, February 06, 2018 18:58:43 number via Digitalmars-d-learn wrote:
> https://dlang.org/phobos/std_file.html#dirEntries
>
> >> The name of each iterated directory entry contains the
> >> absolute path.
>
> it seems to be absolute only if the specified path is absolute,
> or always relative to the parent dir of the specified path.

Then the docs need to be fixed.

- Jonathan M Davis



dirEntries returns relative, not absolute paths

2018-02-06 Thread number via Digitalmars-d-learn

https://dlang.org/phobos/std_file.html#dirEntries
The name of each iterated directory entry contains the 
absolute path.


it seems to be absolute only if the specified path is absolute, 
or always relative to the parent dir of the specified path.


import std.stdio;import std.stdio;

void main()
{
import std.file;
import std.path;

assert(!"dir".exists);
scope(exit) if ("dir".exists) rmdirRecurse("dir");
mkdirRecurse("dir/dir1/dir2/dir3");

writeln("-");
foreach (DirEntry e; dirEntries("dir", SpanMode.breadth))
{
writeln("e: " ~ e);
}

writeln("-");
	foreach (DirEntry e; dirEntries("../" ~ getcwd.baseName ~ 
"/dir", SpanMode.breadth))

{
writeln("e: " ~ e);
}

writeln("-");
	foreach (DirEntry e; dirEntries(getcwd ~ "/dir", 
SpanMode.breadth))

{
writeln("e: " ~ e);
}

//  -
//  e: dir/dir1
//  e: dir/dir1/dir2
//  e: dir/dir1/dir2/dir3
//  -
//  e: ../dTests/dir/dir1
//  e: ../dTests/dir/dir1/dir2
//  e: ../dTests/dir/dir1/dir2/dir3
//  -
//  e: /home/user/dTests/dir/dir1
//  e: /home/user/dTests/dir/dir1/dir2
//  e: /home/user/dTests/dir/dir1/dir2/dir3
}