New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scandir.dirfd() method #83280
Comments
PR in attachment adds a new dirfd() method to the scandir() object (POSIX only). This can be be passed to os.* functions supporting the "dir_fd" parameter, and avoid opening a new fd as in:
At the moment I am not sure if it's possible to also support Windows. |
Why not just os.open the directory yourself and pass it to os.scandir? |
Good point, I didn't consider that. I suppose you're right. =) |
For reference, FindFirstFileW doesn't support handle-relative names, and neither does CreateFileW. At a lower level in Windows NT, NtCreateFile has always supported handle-relative names, but CPython doesn't use the NT API. fd support (not dirfd) could be added to listdir and scandir in Windows. A directory can be listed via GetFileInformationByHandleEx: FileFullDirectoryInfo. This doesn't query the short name, so it may perform better than FindFirstFileW. However, opening a directory with os.open can't be supported. VC++ still hasn't documented the _O_OBTAIN_DIR (0x2000) flag. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: