https://docs.python.org/3/library/stat.html
Python stat module supported "file" types
- "file" is the UNIX sense that everything is a file
Function | Type |
---|---|
stat.S_ISDIR(mode) |
directory |
stat.S_ISCHR(mode) |
character special device file |
stat.S_ISBLK(mode) |
block special device file |
stat.S_ISREG(mode) |
regular file |
stat.S_ISFIFO(mode) |
FIFO (named pipe) |
stat.S_ISLNK(mode) |
symbolic link |
stat.S_ISSOCK(mode) |
socket |
stat.S_ISDOOR(mode) |
door (new Python 3.4) |
stat.S_ISPORT(mode) |
event port (new Python 3.4) |
stat.S_ISWHT(mode) |
whiteout (new Python 3.4) |
What is a door anyway?
- https://en.wikipedia.org/wiki/Doors_(computing)
- Door is a particular kind of file structure that is used as a "remote procedure call" for a "server", "threads" model. Really ever implemented on Solaris
What is an event port anyway?
- https://docs.oracle.com/cd/E19253-01/817-0547/whatsnew-196/index.html
- I think this is a file type that only Solaris really supports that is used for sending events between processes.
- I've been unable to find very good documentation on this one.
What is a whiteout anyway?
- https://lwn.net/Articles/265240/
- https://lwn.net/Articles/325369/
- Summarize:
- A whiteout is a thing that exists on some "overlay" filesystem.
- It represents "there is no file here", when there maybe a file existing at a lower level of the overlay.
- There is question of how good of an idea they are, and support is limited.
- Base linux does not support it, but BSD does.
https://docs.python.org/3/library/os.path.html
Function | Type |
---|---|
os.path.isfile(path) |
regular file |
os.path.isdir(path) |
directory |
os.path.isjunction(path) |
junction (New in version 3.12) |
os.path.islink(path) |
symbolic link |
os.path.ismount(path) |
mount point |
os.path.isdevdrive(path) |
Windows Dev Drive (New in version 3.12) |
What is a junction?
- https://www.computerhope.com/jargon/j/junction.htm
- I think this is like a symlink, but it only works for pointing to directories that are on the same logical volume
What is a Windows Dev Drive?
- https://docs.python.org/3/library/os.path.html#module-os.path
- A Dev Drive is optimized for developer scenarios, and offers faster performance for reading and writing files.
- It is recommended for use for source code, temporary build directories, package caches, and other IO-intensive operations.
- Very strange.
Function | Type |
---|---|
Path.is_dir() |
directory |
Path.is_file() |
regular file |
Path.is_junction() |
junction (New in version 3.12) |
Path.is_mount() |
mount point (New in version 3.7; 3.12: Windows support was added) |
Path.is_symlink() |
symbolic link |
Path.is_socket() |
Unix socket |
Path.is_fifo() |
FIFO |
Path.is_block_device() |
block device |
Path.is_char_device() |
character device |
File Type | os.stat() |
os.path |
pathlib |
---|---|---|---|
regular file | ✅ | ✅ | ✅ |
directory | ✅ | ✅ | ✅ |
symbolic link | ✅ | ✅ | ✅ |
mount point | ❌ | ✅ | ✅ |
socket | ✅ | ❌ | ✅ |
FIFO | ✅ | ❌ | ✅ |
block device | ✅ | ❌ | ✅ |
character device | ✅ | ❌ | ✅ |
junction | ❌ | ✅ | ✅ |
door | ✅ | ❌ | ❌ |
event port | ✅ | ❌ | ❌ |
whiteout | ✅ | ❌ | ❌ |
Windows Dev Drive | ❌ | ✅ | ❌ |