[Python-Dev] Issue 11406: adding os.scandir(), a directory iterator returning stat-like info (original) (raw)
Antoine Pitrou solipsis at pitrou.net
Fri May 10 15:54:11 CEST 2013
- Previous message: [Python-Dev] Issue 11406: adding os.scandir(), a directory iterator returning stat-like info
- Next message: [Python-Dev] Issue 11406: adding os.scandir(), a directory iterator returning stat-like info
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Le Fri, 10 May 2013 15:46:21 +0200, Christian Heimes <christian at python.org> a écrit :
Am 10.05.2013 14:16, schrieb Antoine Pitrou: > But what if some systems return more than the file type and less > than a full stat result? The general problem is POSIX's terrible > inertia. I feel that a stat result with some None fields would be > an acceptable compromise here.
POSIX only defines the dino and dname members of struct dirent. Linux, BSD and probably some other platforms also happen to provide dtype. The other members of struct dirent (dreclen, dnamlen) aren't useful in Python space by themselves. dtype and stmode aren't compatible in any way. As you know stmode also contains POSIX permission information. The file type is encoded with a different set of bits, too. Future file types aren't mapped to SIF* constants for stmode.
Thank you and Ronald for clarifying. This does make the API design a bit bothersome. We want to expose as much information as possible in a cross-platform way and with a flexible granularity, but doing so might require a gazillion of namedtuple fields (platonically, as much as one field per stat bit).
For dino you also need the device number from the directory because the inode is only unique within a device.
But hopefully you've already stat'ed the directory ;)
Regards
Antoine.
- Previous message: [Python-Dev] Issue 11406: adding os.scandir(), a directory iterator returning stat-like info
- Next message: [Python-Dev] Issue 11406: adding os.scandir(), a directory iterator returning stat-like info
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]