[issue12898] add opendir() for POSIX platforms

2011-09-05 Thread STINNER Victor
STINNER Victor 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 __

[issue12898] add opendir() for POSIX platforms

2011-09-05 Thread STINNER Victor
Changes by STINNER Victor : -- resolution: -> works for me status: open -> closed ___ Python tracker ___ ___ Python-bugs-list mailing

[issue12898] add opendir() for POSIX platforms

2011-09-05 Thread Larry Hastings
Larry Hastings 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 directory fds." T

[issue12898] add opendir() for POSIX platforms

2011-09-05 Thread Antoine Pitrou
Antoine Pitrou 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", os.O_RD

[issue12898] add opendir() for POSIX platforms

2011-09-05 Thread Larry Hastings
Larry Hastings 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 added the comment: Well, is there any case where fdlistdir() is not sufficient? -- nosy: +pitrou ___ Python tracker ___ __

[issue12898] add opendir() for POSIX platforms

2011-09-05 Thread Larry Hastings
Larry Hastings 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 opendir-returns-a-DIR-not-a-fd thing, hopeful

[issue12898] add opendir() for POSIX platforms

2011-09-05 Thread Ross Lagerwall
Ross Lagerwall 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 like os.openat() Chee

[issue12898] add opendir() for POSIX platforms

2011-09-05 Thread Larry Hastings
New submission from Larry Hastings : 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 internal, in os.listdir()

[issue12898] add opendir() for POSIX platforms

2011-09-05 Thread Ross Lagerwall
Ross Lagerwall 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. -- ___ Python tracker