On Fri, Jul 1, 2011 at 19:04, Peter Samuelson <pe...@p12n.org> wrote: > >> > Especially since the "common case", as you put it, is that the open() >> > returns ENOENT, file not found. _That_ case may or may not be >> > expensive, but it's quite different from the usual consideration of >> > whether stat() is expensive. Not least because stat() is usually >> > considered in context where a file _does_ exist and various information >> > about the file gets looked up to populate the stat structure. > > [Ivan Zhakov] >> Btw on Windows dry open() takes a lot more time than stat(). I don't why. > > Wait ... you're saying open() that returns 'file not found' is more > expensive than a stat()? It is harder for the OS to determine that a > file does not exist and thus cannot be opened, than it is to gather > various fields of information about a file that _does_ exist? > > I hate to pick on Windows for its design, because that's so cliche ... > but that sounds like a pretty poor filesystem design. I was wrong: we found this issue on ext2fs. See r1103749: http://svn.apache.org/viewvc?view=revision&revision=1103749
I didn't tested difference in performance between stat() and open() on Windows, but Stefan2 tested in on ext2fs. -- Ivan Zhakov