Telling directories from files (Was: statcache.lstat?)

Some of the recent systems have the file type in the directories (44ffs, NTFS, ext2 with "filetype" feature); in addition, recent C libraries expose the file type through getdents. E.g. on Linux, struct dirent is struct dirent64 { __ino64_t d_ino; __off64_t d_off; unsigned short int d_reclen; unsigned char d_type; char d_name[256]; }; In this type, d_type can take the values DT_UNKNOWN DT_FIFO DT_CHR DT_DIR DT_BLK DT_REG DT_LNK DT_SOCK DT_WHT Likewise, on Win32, FindFirstFile will return not only the file name, but also whether it is a directory, access times, alternate names, etc. I always meant to expose the file type to Python, to speed up things that only do stat to tell apart directories from non-directories. Of course, doing this in a portable, backwards-compatible manner may become a challenge, especially if you want os.listdir to expose this information. I think I'll write a PEP. Regards, Martin
participants (1)
-
Martin von Loewis