On Tuesday, August 30, 2011 10:39 Nick Treleaven wrote: > Hi, > With the attached source file on Windows, dmd 2.054, I'm not getting an > exception when the path doesn't exist. If I uncomment the foreach line, > the exception is thrown. Should I file this in bugzilla?
So, what exactly is the problem? Is the issue that isDir isn't throwing or that dirEntries isn't throwing? isDir should definitely throw if the path doesn't exist, but I'm not sure that dirEntries will. It'll throw once you try and iterate over it, but dirEntries returns a range of DirEntrys which is lazy. So, there's a decent chance that it doesn't actually do anything with the path that you gave it until you try and iterate it. I'd have to look at the implementation though to see whether that's the case. Regardless, if the issue is that dirEntries doesn't throw, and that you only get an exception when you actually iterate over the return value from dirEntries, then I don't think that that's really a bug. Assuming that it doesn't currently throw on a bad path until you iterate, it may or may not be desirable to make it so that dirEntries does an additional check to verify that the path is valid, but since it would throw once you started iterating, I don't think that it's really a problem - especially if checking whether the path is valid before iteration means making an additional system call. - Jonathan M Davis