[issue12898] add opendir() for POSIX platforms

2011-09-05 Thread Ross Lagerwall
Ross Lagerwall rosslagerw...@gmail.com added the comment: Also see fdopendir(3) which allows you to pass an open file descriptor to get a C dirent struct. This is implemented in the os module too but instead of returning a struct, it returns a list. --

[issue12898] add opendir() for POSIX platforms

2011-09-05 Thread Larry Hastings
New submission from Larry Hastings la...@hastings.org: With the recent spate of POSIX *at() functions added to os, we now have a bunch of places in the API that take directory fds. But afaict there's no way to get a directory fd in Python! The only calls to opendir() in the tree are

[issue12898] add opendir() for POSIX platforms

2011-09-05 Thread Ross Lagerwall
Ross Lagerwall rosslagerw...@gmail.com added the comment: opendir opens a C dirent structure with an underlying file descriptor. However, to open a directory file descriptor, simple use: os.open(/tmp, os.O_RDONLY) This can then be used as the fd to the functions which require a directory fd

[issue12898] add opendir() for POSIX platforms

2011-09-05 Thread Larry Hastings
Larry Hastings la...@hastings.org added the comment: Well, there's no os.fdopendir(); I think you're referring to fdlistdir(), which uses the C function fdopendir() internally. The DIR structure is not exposed to the Python caller at any point. I did miss the whole

[issue12898] add opendir() for POSIX platforms

2011-09-05 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Well, is there any case where fdlistdir() is not sufficient? -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12898 ___

[issue12898] add opendir() for POSIX platforms

2011-09-05 Thread Larry Hastings
Larry Hastings la...@hastings.org added the comment: fdlistdir() is largely irrelevant to the discussion. I was proposing adding a function to open directory fds, because there isn't one; fdlistdir(), like many other POSIX functions available in Python, consumes directory fds. --

[issue12898] add opendir() for POSIX platforms

2011-09-05 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: I was proposing adding a function to open directory fds, because there isn't one; fdlistdir(), like many other POSIX functions available in Python, consumes directory fds. I don't think I understand. This already works: fd = os.open(Misc,

[issue12898] add opendir() for POSIX platforms

2011-09-05 Thread Larry Hastings
Larry Hastings la...@hastings.org added the comment: Is there anything you want to do on a directory fd except listing its contents? In the first message in this bug, I wrote: With the recent spate of POSIX *at() functions added to os, we now have a bunch of places in the API that take

[issue12898] add opendir() for POSIX platforms

2011-09-05 Thread STINNER Victor
Changes by STINNER Victor victor.stin...@haypocalc.com: -- resolution: - works for me status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12898 ___

[issue12898] add opendir() for POSIX platforms

2011-09-05 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: At the time I created this ticket I didn't realize you could just call open() on a directory. Yes, os.open or os.openat. -- nosy: +haypo ___ Python tracker rep...@bugs.python.org