What's the difference between isdir() and S_ISDIR()?
I am reading linux's source code and I see 2 functions:
isdir() and S_ISDIR()
I can't find related definitions of them. What's the difference between isdir() and S_ISDIR() ?
Frequently Quite Prolix
More forums, better answers, eh? http://www.codeguru.com/forum/showth...hreadid=447132
 Alright, here's my shot at it . . . have to show we're better than codeguru, after all.
As far as I can tell, isdir() isn't very standard. http://genome.jouy.inra.fr/doc/genom...leio/isdir.htm
S_ISDIR(), on the other hand, is a very common macro in <sys/stat.h>, and is probably POSIX standard.
And another thing -- S_ISDIR() is called on the result of stat(), and it just checks an integer, so it's very efficient. isdir() appears to take a filename as a string, however, so opening and checking that would be pretty inefficient.
For more information about stat(): http://www.opengroup.org/onlinepubs/...ions/stat.html [/edit]
Last edited by dwks; 02-27-2008 at 01:26 AM.
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/