Bug 8298 – dirEntries special linux file in Home dir

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-06-25T11:17:00Z
Last change time
2015-06-09T05:15:17Z
Keywords
pull
Assigned to
nobody
Creator
bioinfornatics

Comments

Comment #0 by bioinfornatics — 2012-06-25T11:17:25Z
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 ); }
Comment #1 by dlang-bugzilla — 2012-12-21T21:25:22Z
How to create such a special file, in order to reproduce the problem?
Comment #2 by mike — 2013-02-16T08:13:38Z
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.
Comment #3 by mike — 2013-11-13T13:15:52Z
*** Issue 11501 has been marked as a duplicate of this issue. ***
Comment #4 by timothee.cour2 — 2014-01-07T15:41:11Z
Is anything blocking the pull ?
Comment #5 by github-bugzilla — 2014-01-07T16:23:53Z
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.
Comment #6 by timothee.cour2 — 2014-01-07T16:39:58Z
so shall we mark this as FIXED?
Comment #7 by dlang-bugzilla — 2014-01-08T01:33:34Z
Yes, that pull should have fixed all relevant problems.