http://d.puremagic.com/issues/show_bug.cgi?id=3848
Summary: functions in std.file don't take symbolic links into account Product: D Version: 2.040 Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nob...@puremagic.com ReportedBy: jmdavisp...@gmail.com --- Comment #0 from Jonathan M Davis <jmdavisp...@gmail.com> 2010-02-24 00:24:31 PST --- Created an attachment (id=572) Changes for std.file.d to make it work with symlinks. At present, if you call isfile() or isdir() on a symbolic link, it reports on what the link points to rather than the link itself. Presumably this is fine on Windows since as far as I know, Windows doesn't have symbolic links. But it is a big problem for Linux. The other problem is rmdirRecursive(). At present, I believe that it currently would follow symbolic links to directories rather than just deleting the symlink itself. Ideally, it would not follow symlinks. I have included a patch which I believe fixes the problems. Whether it's the best solution to the problem, I don't know. I added getLinkAttributes() which uses lstat instead of stat and make isdir() and isfile() use getLinkAttributes() rather than getAttributes(). I also added issymlink() to go with isdir() and isfile(). DirEntry was changed to use lstat as well. That should fix, isfile(), isdir(), and rmdirRecursive(). Most of the other functions like lastModified() continue to use fstat, so they continue to give information on the file which is pointed to rather than the symlink, which I think is what we want. The one wart is that having DirEntry use lstat means that all of the attributes that it gives are for the symlink itself which is not always what we want. So, I added a followLink() function which returns a DirEntry with the values for stat if it's a symbolic link or just returns a copy of the DirEntry if it's not. followLink() can almost certainly been done in a cleaner manner. I'd have used init, but I don't know how to get dirent for a single file rather than a whole directory. So, it uses stat and then checks the mode to figure out which value to set d_type for. DT_WHT is currently not used (it's commented out) because I have no clue what it represents, so I don't know what mode value from stat it corresponds to. In any case, if my patch isn't quite what you'd want to use, hopefully it's at least a step in the right direction. Hopefully the patch is in an appropriate format. It has changes for std.file.d -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------