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() ?
Printable View
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() ?
More forums, better answers, eh? ;) http://www.codeguru.com/forum/showth...hreadid=447132
[edit] Alright, here's my shot at it . . . have to show we're better than codeguru, after all. :D
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]