How to get a directory file descriptor?

alex23 wuwei23 at gmail.com
Wed Nov 26 08:20:50 EST 2008


On Nov 26, 8:56 pm, Cong Ma <c... at mail.bnu.edu.cn> wrote:
> Thanks for your reply. I checked my Python 2.5 install on Linux and there's the
> O_DIRECTORY flag. However this is not mentioned anywhere in the Library Reference.

Yes, I just noticed that myself.

>        O_DIRECTORY
>               If pathname is not a directory, cause the open  to  fail.   This
>               flag is Linux-specific, and was added in kernel version 2.1.126,

Well, that certainly explains it's absence :)

> Note the "should not be used outside of the implementation of opendir(3)" part.
> Does that mean using Python's os.open() with the O_DIRECTORY flag is a Bad
> Thing?

I'm sorry, that's outside of my knowledge. But it seemed to work fine
when I tried it.




More information about the Python-list mailing list