Possible Duplicate:
Does readdir() guarantee an order?
I'm guessing this isn't the case, and I'd need to manually check the name of each entry instead of just skipping the first couple. Is that correct?
Possible Duplicate:
Does readdir() guarantee an order?
I'm guessing this isn't the case, and I'd need to manually check the name of each entry instead of just skipping the first couple. Is that correct?
The POSIX standard does not guarantee anything about the order of directory entries whatsoever. As such, if you're interested in filtering out .
and ..
, you do need to compare for them.
No, you should never rely on finding .
and ..
first (although it almost always happens).
I remember one case when I had problems with such an assuption (on ReiserFS they were not found first, but it was an old version of ReiserFS, now it may be different).
It is not in the standard, but I have never seen them in any other place, but the first two. But, just in case, if you don't realy mind the time that much, I would do the check.