digitalmars.D.learn - dirEntries returns relative, not absolute paths
- number (45/47) Feb 06 2018 it seems to be absolute only if the specified path is absolute,
- Jonathan M Davis (3/8) Feb 06 2018 Then the docs need to be fixed.
- Timothee Cour (3/13) Feb 06 2018 https://github.com/dlang/phobos/pull/6133
https://dlang.org/phobos/std_file.html#dirEntriesit 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 }The name of each iterated directory entry contains the absolute path.
Feb 06 2018
On Tuesday, February 06, 2018 18:58:43 number via Digitalmars-d-learn wrote:https://dlang.org/phobos/std_file.html#dirEntriesThen the docs need to be fixed. - Jonathan M Davisit seems to be absolute only if the specified path is absolute, or always relative to the parent dir of the specified path.The name of each iterated directory entry contains the absolute path.
Feb 06 2018
https://github.com/dlang/phobos/pull/6133 On Tue, Feb 6, 2018 at 1:40 PM, Jonathan M Davis via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:On Tuesday, February 06, 2018 18:58:43 number via Digitalmars-d-learn wrote:https://dlang.org/phobos/std_file.html#dirEntriesThen the docs need to be fixed. - Jonathan M Davisit seems to be absolute only if the specified path is absolute, or always relative to the parent dir of the specified path.The name of each iterated directory entry contains the absolute path.
Feb 06 2018