The stat module contains a
number of variables used in encoding and decoding various
items returned by certain methods in the
os module,
such as
stat() and chmod().
First, there are constants for indexing the components of a “status tuple” such as that returned by os.stat():
ST_MODE | The file's permissions. |
ST_INO | The i-node number. |
ST_DEV | The device number. |
ST_NLINK | The number of hard links. |
ST_UID | The user ID. |
ST_GID | The group ID. |
ST_SIZE | The current size in bytes. |
ST_ATIME | The epoch time of last access (see the
time module for interpretation
of times). |
ST_MTIME | The epoch time of last modification. |
ST_CTIME | The epoch time of the file's creation. |
The following functions are defined in the
stat module for testing a mode
value ,
where m
is the mST_MODE element of the
status tuple. Each function is a predicate:
S_ISDIR( | Is this a directory? |
S_ISCHR( | Is this a character device? |
S_ISBLK( | Is this a block device? |
S_ISREG( | Is this an ordinary file? |
S_ISFIFO( | Is this a FIFO? |
S_ISLNK( | Is this a soft (symbolic) link? |
S_ISSOCK( | Is this a socket? |
These constants are defined for use as mask values in
testing and assembling permission values such as those
returned by os.stat():
S_ISUID | SUID (set user ID) bit. |
S_ISGID | SGID (set group ID) bit. |
S_IRUSR | Owner read permission. |
S_IWUSR | Owner write permission. |
S_IXUSR | Owner execute permission. |
S_IRGRP | Group read permission. |
S_IWGRP | Group write permission. |
S_IXGRP | Group execute permission. |
S_IROTH | World read permission. |
S_IWOTH | World write permission. |
S_IXOTH | World execute permission. |