when i use std.file.dirEntries it fail when scanning the home directory(linux) because thay are some special files e.g: Failed to stat file `./.pulse/b86d160eca2ebd0f61847c4600000013-runtime' it will be good to have a way to list both files an dir in any case ... import std.file; import std.algorithm; import std.stdio; import std.path; import std.array; void main(){ DirEntry[] dFiles = array( dirEntries( ".", SpanMode.depth ).filter!( ( a ) => a.name.extension == ".d" ) ); foreach( d; dFiles ) writeln( d ); }
How to create such a special file, in order to reproduce the problem?
The special file as an broken symlink. The Exception is thrown because stat return an error code in that case. With this pull request: https://github.com/D-Programming-Language/phobos/pull/1142 I've changed ensureStatDone so it also tries lstat if stat fails as to support broken symlinks in DirEntry.
*** Issue 11501 has been marked as a duplicate of this issue. ***
Is anything blocking the pull ?
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/eb4d5a0572da733c492ef3b75ff12e74a8f0a522 Fix Issue #8298, Don't throw exceptions on broken symlinks. Using dirEntries to loop trough all the files/directories in a directory will curently throw an Exception when encountering an broken symlink. Whit this change DirEntry will no longer throw an Exception for broken symlinks, but in that case isDir and isFile will return flase while isSymlink returns true. https://github.com/D-Programming-Language/phobos/commit/1d7912c6791bd0a84f67370f4462b922b996701c Merge pull request #1142 from MikeWey/Issue8298 Fix Issue #8298, Don't throw exceptions on broken symlinks.
so shall we mark this as FIXED?
Yes, that pull should have fixed all relevant problems.