www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20109] New: DirEntries() fails on symbolic links to


          Issue ID: 20109
           Summary: DirEntries() fails on symbolic links to non-existent
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: ckatko gmail.com

DirEntries() fails on symbolic links to non-existent file. I just had this bug
show up.

 - I'm making a program that scans all the files in a path and computes their
hashes. DirEntries keeps exploding on a random symlink on my hard drive.

 - I passed "false" to "followSymlink" in DirEntries(), but it still fails
regardless and throws an exception. 

 - The reason I believe, is that this random spurious file (cmt_drv.la) I have
is a symlink to "../cmt_drv.la", and that file doesn't exist. 


commandline args:
0 ./dup
1 /home/novous/Downloads/DOWNLOADS BUFFER/xf86-input-cmt/src/.libs/

object.Exception std/file.d(3219): Failed to stat file
`/home/novous/Downloads/DOWNLOADS BUFFER/xf86-input-cmt/src/.libs/cmt_drv.la'
??:? pure  safe void
std.exception.bailOut!(Exception).bailOut(immutable(char)[], ulong,
const(char[])) [0x6cdb691e]
??:? pure  safe bool std.exception.enforce!(Exception, bool).enforce(bool, lazy
const(char)[], immutable(char)[], ulong) [0x6cd9f9e1]
??:?  trusted void std.file.DirEntry._ensureStatDone() [0x6cd772ee]
??:?  property  safe ulong std.file.DirEntry.size() [0x6cd7713c]
??:? _Dmain [0x6cd58c81]

on github here:


It appears "stat" is failing.

This might be key: I'm trying to run sort!("a.size > b.size") on the returned
DirEntries, and while sorting it calls .size() which then invokes the stat

This program works fine until I ran into this edge-case. I can provide code
snippets and clarification as needed. 


Aug 05 2019