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.
--
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
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
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
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
___
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.
--
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,
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
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
___
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
10 matches
Mail list logo